text
stringlengths
2
1.1M
id
stringlengths
11
117
metadata
dict
__index_level_0__
int64
0
885
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package acmetest provides types for testing acme and autocert packages. // // TODO: Consider moving this to x/crypto/acme/internal/acmetest for acme tests as well. package acmetest import ( "context" "crypto" "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "crypto/rsa" "crypto/tls" "crypto/x509" "crypto/x509/pkix" "encoding/asn1" "encoding/base64" "encoding/json" "encoding/pem" "fmt" "io" "math/big" "net" "net/http" "net/http/httptest" "path" "strconv" "strings" "sync" "testing" "time" "golang.org/x/crypto/acme" ) // CAServer is a simple test server which implements ACME spec bits needed for testing. type CAServer struct { rootKey crypto.Signer rootCert []byte // DER encoding rootTemplate *x509.Certificate t *testing.T server *httptest.Server issuer pkix.Name challengeTypes []string url string roots *x509.CertPool eabRequired bool mu sync.Mutex certCount int // number of issued certs acctRegistered bool // set once an account has been registered domainAddr map[string]string // domain name to addr:port resolution domainGetCert map[string]getCertificateFunc // domain name to GetCertificate function domainHandler map[string]http.Handler // domain name to Handle function validAuthz map[string]*authorization // valid authz, keyed by domain name authorizations []*authorization // all authz, index is used as ID orders []*order // index is used as order ID errors []error // encountered client errors } type getCertificateFunc func(hello *tls.ClientHelloInfo) (*tls.Certificate, error) // NewCAServer creates a new ACME test server. The returned CAServer issues // certs signed with the CA roots available in the Roots field. func NewCAServer(t *testing.T) *CAServer { ca := &CAServer{t: t, challengeTypes: []string{"fake-01", "tls-alpn-01", "http-01"}, domainAddr: make(map[string]string), domainGetCert: make(map[string]getCertificateFunc), domainHandler: make(map[string]http.Handler), validAuthz: make(map[string]*authorization), } ca.server = httptest.NewUnstartedServer(http.HandlerFunc(ca.handle)) r, err := rand.Int(rand.Reader, big.NewInt(1000000)) if err != nil { panic(fmt.Sprintf("rand.Int: %v", err)) } ca.issuer = pkix.Name{ Organization: []string{"Test Acme Co"}, CommonName: "Root CA " + r.String(), } return ca } func (ca *CAServer) generateRoot() { key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { panic(fmt.Sprintf("ecdsa.GenerateKey: %v", err)) } tmpl := &x509.Certificate{ SerialNumber: big.NewInt(1), Subject: ca.issuer, NotBefore: time.Now(), NotAfter: time.Now().Add(365 * 24 * time.Hour), KeyUsage: x509.KeyUsageCertSign, BasicConstraintsValid: true, IsCA: true, } der, err := x509.CreateCertificate(rand.Reader, tmpl, tmpl, &key.PublicKey, key) if err != nil { panic(fmt.Sprintf("x509.CreateCertificate: %v", err)) } cert, err := x509.ParseCertificate(der) if err != nil { panic(fmt.Sprintf("x509.ParseCertificate: %v", err)) } ca.roots = x509.NewCertPool() ca.roots.AddCert(cert) ca.rootKey = key ca.rootCert = der ca.rootTemplate = tmpl } // IssuerName sets the name of the issuing CA. func (ca *CAServer) IssuerName(name pkix.Name) *CAServer { if ca.url != "" { panic("IssuerName must be called before Start") } ca.issuer = name return ca } // ChallengeTypes sets the supported challenge types. func (ca *CAServer) ChallengeTypes(types ...string) *CAServer { if ca.url != "" { panic("ChallengeTypes must be called before Start") } ca.challengeTypes = types return ca } // URL returns the server address, after Start has been called. func (ca *CAServer) URL() string { if ca.url == "" { panic("URL called before Start") } return ca.url } // Roots returns a pool cointaining the CA root. func (ca *CAServer) Roots() *x509.CertPool { if ca.url == "" { panic("Roots called before Start") } return ca.roots } // ExternalAccountRequired makes an EAB JWS required for account registration. func (ca *CAServer) ExternalAccountRequired() *CAServer { if ca.url != "" { panic("ExternalAccountRequired must be called before Start") } ca.eabRequired = true return ca } // Start starts serving requests. The server address becomes available in the // URL field. func (ca *CAServer) Start() *CAServer { if ca.url == "" { ca.generateRoot() ca.server.Start() ca.t.Cleanup(ca.server.Close) ca.url = ca.server.URL } return ca } func (ca *CAServer) serverURL(format string, arg ...interface{}) string { return ca.server.URL + fmt.Sprintf(format, arg...) } func (ca *CAServer) addr(domain string) (string, bool) { ca.mu.Lock() defer ca.mu.Unlock() addr, ok := ca.domainAddr[domain] return addr, ok } func (ca *CAServer) getCert(domain string) (getCertificateFunc, bool) { ca.mu.Lock() defer ca.mu.Unlock() f, ok := ca.domainGetCert[domain] return f, ok } func (ca *CAServer) getHandler(domain string) (http.Handler, bool) { ca.mu.Lock() defer ca.mu.Unlock() h, ok := ca.domainHandler[domain] return h, ok } func (ca *CAServer) httpErrorf(w http.ResponseWriter, code int, format string, a ...interface{}) { s := fmt.Sprintf(format, a...) ca.t.Errorf(format, a...) http.Error(w, s, code) } // Resolve adds a domain to address resolution for the ca to dial to // when validating challenges for the domain authorization. func (ca *CAServer) Resolve(domain, addr string) { ca.mu.Lock() defer ca.mu.Unlock() ca.domainAddr[domain] = addr } // ResolveGetCertificate redirects TLS connections for domain to f when // validating challenges for the domain authorization. func (ca *CAServer) ResolveGetCertificate(domain string, f getCertificateFunc) { ca.mu.Lock() defer ca.mu.Unlock() ca.domainGetCert[domain] = f } // ResolveHandler redirects HTTP requests for domain to f when // validating challenges for the domain authorization. func (ca *CAServer) ResolveHandler(domain string, h http.Handler) { ca.mu.Lock() defer ca.mu.Unlock() ca.domainHandler[domain] = h } type discovery struct { NewNonce string `json:"newNonce"` NewAccount string `json:"newAccount"` NewOrder string `json:"newOrder"` NewAuthz string `json:"newAuthz"` Meta discoveryMeta `json:"meta,omitempty"` } type discoveryMeta struct { ExternalAccountRequired bool `json:"externalAccountRequired,omitempty"` } type challenge struct { URI string `json:"uri"` Type string `json:"type"` Token string `json:"token"` } type authorization struct { Status string `json:"status"` Challenges []challenge `json:"challenges"` domain string id int } type order struct { Status string `json:"status"` AuthzURLs []string `json:"authorizations"` FinalizeURL string `json:"finalize"` // CSR submit URL CertURL string `json:"certificate"` // already issued cert leaf []byte // issued cert in DER format } func (ca *CAServer) handle(w http.ResponseWriter, r *http.Request) { ca.t.Logf("%s %s", r.Method, r.URL) w.Header().Set("Replay-Nonce", "nonce") // TODO: Verify nonce header for all POST requests. switch { default: ca.httpErrorf(w, http.StatusBadRequest, "unrecognized r.URL.Path: %s", r.URL.Path) // Discovery request. case r.URL.Path == "/": resp := &discovery{ NewNonce: ca.serverURL("/new-nonce"), NewAccount: ca.serverURL("/new-account"), NewOrder: ca.serverURL("/new-order"), Meta: discoveryMeta{ ExternalAccountRequired: ca.eabRequired, }, } if err := json.NewEncoder(w).Encode(resp); err != nil { panic(fmt.Sprintf("discovery response: %v", err)) } // Nonce requests. case r.URL.Path == "/new-nonce": // Nonce values are always set. Nothing else to do. return // Client key registration request. case r.URL.Path == "/new-account": ca.mu.Lock() defer ca.mu.Unlock() if ca.acctRegistered { ca.httpErrorf(w, http.StatusServiceUnavailable, "multiple accounts are not implemented") return } ca.acctRegistered = true var req struct { ExternalAccountBinding json.RawMessage } if err := decodePayload(&req, r.Body); err != nil { ca.httpErrorf(w, http.StatusBadRequest, err.Error()) return } if ca.eabRequired && len(req.ExternalAccountBinding) == 0 { ca.httpErrorf(w, http.StatusBadRequest, "registration failed: no JWS for EAB") return } // TODO: Check the user account key against a ca.accountKeys? w.Header().Set("Location", ca.serverURL("/accounts/1")) w.WriteHeader(http.StatusCreated) w.Write([]byte("{}")) // New order request. case r.URL.Path == "/new-order": var req struct { Identifiers []struct{ Value string } } if err := decodePayload(&req, r.Body); err != nil { ca.httpErrorf(w, http.StatusBadRequest, err.Error()) return } ca.mu.Lock() defer ca.mu.Unlock() o := &order{Status: acme.StatusPending} for _, id := range req.Identifiers { z := ca.authz(id.Value) o.AuthzURLs = append(o.AuthzURLs, ca.serverURL("/authz/%d", z.id)) } orderID := len(ca.orders) ca.orders = append(ca.orders, o) w.Header().Set("Location", ca.serverURL("/orders/%d", orderID)) w.WriteHeader(http.StatusCreated) if err := json.NewEncoder(w).Encode(o); err != nil { panic(err) } // Existing order status requests. case strings.HasPrefix(r.URL.Path, "/orders/"): ca.mu.Lock() defer ca.mu.Unlock() o, err := ca.storedOrder(strings.TrimPrefix(r.URL.Path, "/orders/")) if err != nil { ca.httpErrorf(w, http.StatusBadRequest, err.Error()) return } if err := json.NewEncoder(w).Encode(o); err != nil { panic(err) } // Accept challenge requests. case strings.HasPrefix(r.URL.Path, "/challenge/"): parts := strings.Split(r.URL.Path, "/") typ, id := parts[len(parts)-2], parts[len(parts)-1] ca.mu.Lock() supported := false for _, suppTyp := range ca.challengeTypes { if suppTyp == typ { supported = true } } a, err := ca.storedAuthz(id) ca.mu.Unlock() if !supported { ca.httpErrorf(w, http.StatusBadRequest, "unsupported challenge: %v", typ) return } if err != nil { ca.httpErrorf(w, http.StatusBadRequest, "challenge accept: %v", err) return } ca.validateChallenge(a, typ) w.Write([]byte("{}")) // Get authorization status requests. case strings.HasPrefix(r.URL.Path, "/authz/"): var req struct{ Status string } decodePayload(&req, r.Body) deactivate := req.Status == "deactivated" ca.mu.Lock() defer ca.mu.Unlock() authz, err := ca.storedAuthz(strings.TrimPrefix(r.URL.Path, "/authz/")) if err != nil { ca.httpErrorf(w, http.StatusNotFound, "%v", err) return } if deactivate { // Note we don't invalidate authorized orders as we should. authz.Status = "deactivated" ca.t.Logf("authz %d is now %s", authz.id, authz.Status) ca.updatePendingOrders() } if err := json.NewEncoder(w).Encode(authz); err != nil { panic(fmt.Sprintf("encoding authz %d: %v", authz.id, err)) } // Certificate issuance request. case strings.HasPrefix(r.URL.Path, "/new-cert/"): ca.mu.Lock() defer ca.mu.Unlock() orderID := strings.TrimPrefix(r.URL.Path, "/new-cert/") o, err := ca.storedOrder(orderID) if err != nil { ca.httpErrorf(w, http.StatusBadRequest, err.Error()) return } if o.Status != acme.StatusReady { ca.httpErrorf(w, http.StatusForbidden, "order status: %s", o.Status) return } // Validate CSR request. var req struct { CSR string `json:"csr"` } decodePayload(&req, r.Body) b, _ := base64.RawURLEncoding.DecodeString(req.CSR) csr, err := x509.ParseCertificateRequest(b) if err != nil { ca.httpErrorf(w, http.StatusBadRequest, err.Error()) return } // Issue the certificate. der, err := ca.leafCert(csr) if err != nil { ca.httpErrorf(w, http.StatusBadRequest, "new-cert response: ca.leafCert: %v", err) return } o.leaf = der o.CertURL = ca.serverURL("/issued-cert/%s", orderID) o.Status = acme.StatusValid if err := json.NewEncoder(w).Encode(o); err != nil { panic(err) } // Already issued cert download requests. case strings.HasPrefix(r.URL.Path, "/issued-cert/"): ca.mu.Lock() defer ca.mu.Unlock() o, err := ca.storedOrder(strings.TrimPrefix(r.URL.Path, "/issued-cert/")) if err != nil { ca.httpErrorf(w, http.StatusBadRequest, err.Error()) return } if o.Status != acme.StatusValid { ca.httpErrorf(w, http.StatusForbidden, "order status: %s", o.Status) return } w.Header().Set("Content-Type", "application/pem-certificate-chain") pem.Encode(w, &pem.Block{Type: "CERTIFICATE", Bytes: o.leaf}) pem.Encode(w, &pem.Block{Type: "CERTIFICATE", Bytes: ca.rootCert}) } } // storedOrder retrieves a previously created order at index i. // It requires ca.mu to be locked. func (ca *CAServer) storedOrder(i string) (*order, error) { idx, err := strconv.Atoi(i) if err != nil { return nil, fmt.Errorf("storedOrder: %v", err) } if idx < 0 { return nil, fmt.Errorf("storedOrder: invalid order index %d", idx) } if idx > len(ca.orders)-1 { return nil, fmt.Errorf("storedOrder: no such order %d", idx) } ca.updatePendingOrders() return ca.orders[idx], nil } // storedAuthz retrieves a previously created authz at index i. // It requires ca.mu to be locked. func (ca *CAServer) storedAuthz(i string) (*authorization, error) { idx, err := strconv.Atoi(i) if err != nil { return nil, fmt.Errorf("storedAuthz: %v", err) } if idx < 0 { return nil, fmt.Errorf("storedAuthz: invalid authz index %d", idx) } if idx > len(ca.authorizations)-1 { return nil, fmt.Errorf("storedAuthz: no such authz %d", idx) } return ca.authorizations[idx], nil } // authz returns an existing valid authorization for the identifier or creates a // new one. It requires ca.mu to be locked. func (ca *CAServer) authz(identifier string) *authorization { authz, ok := ca.validAuthz[identifier] if !ok { authzId := len(ca.authorizations) authz = &authorization{ id: authzId, domain: identifier, Status: acme.StatusPending, } for _, typ := range ca.challengeTypes { authz.Challenges = append(authz.Challenges, challenge{ Type: typ, URI: ca.serverURL("/challenge/%s/%d", typ, authzId), Token: challengeToken(authz.domain, typ, authzId), }) } ca.authorizations = append(ca.authorizations, authz) } return authz } // leafCert issues a new certificate. // It requires ca.mu to be locked. func (ca *CAServer) leafCert(csr *x509.CertificateRequest) (der []byte, err error) { ca.certCount++ // next leaf cert serial number leaf := &x509.Certificate{ SerialNumber: big.NewInt(int64(ca.certCount)), Subject: pkix.Name{Organization: []string{"Test Acme Co"}}, NotBefore: time.Now(), NotAfter: time.Now().Add(90 * 24 * time.Hour), KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, DNSNames: csr.DNSNames, BasicConstraintsValid: true, } if len(csr.DNSNames) == 0 { leaf.DNSNames = []string{csr.Subject.CommonName} } return x509.CreateCertificate(rand.Reader, leaf, ca.rootTemplate, csr.PublicKey, ca.rootKey) } // LeafCert issues a leaf certificate. func (ca *CAServer) LeafCert(name, keyType string, notBefore, notAfter time.Time) *tls.Certificate { if ca.url == "" { panic("LeafCert called before Start") } ca.mu.Lock() defer ca.mu.Unlock() var pk crypto.Signer switch keyType { case "RSA": var err error pk, err = rsa.GenerateKey(rand.Reader, 1024) if err != nil { ca.t.Fatal(err) } case "ECDSA": var err error pk, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { ca.t.Fatal(err) } default: panic("LeafCert: unknown key type") } ca.certCount++ // next leaf cert serial number leaf := &x509.Certificate{ SerialNumber: big.NewInt(int64(ca.certCount)), Subject: pkix.Name{Organization: []string{"Test Acme Co"}}, NotBefore: notBefore, NotAfter: notAfter, KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageKeyEncipherment, ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, DNSNames: []string{name}, BasicConstraintsValid: true, } der, err := x509.CreateCertificate(rand.Reader, leaf, ca.rootTemplate, pk.Public(), ca.rootKey) if err != nil { ca.t.Fatal(err) } return &tls.Certificate{ Certificate: [][]byte{der}, PrivateKey: pk, } } func (ca *CAServer) validateChallenge(authz *authorization, typ string) { var err error switch typ { case "tls-alpn-01": err = ca.verifyALPNChallenge(authz) case "http-01": err = ca.verifyHTTPChallenge(authz) default: panic(fmt.Sprintf("validation of %q is not implemented", typ)) } ca.mu.Lock() defer ca.mu.Unlock() if err != nil { authz.Status = "invalid" } else { authz.Status = "valid" ca.validAuthz[authz.domain] = authz } ca.t.Logf("validated %q for %q, err: %v", typ, authz.domain, err) ca.t.Logf("authz %d is now %s", authz.id, authz.Status) ca.updatePendingOrders() } func (ca *CAServer) updatePendingOrders() { // Update all pending orders. // An order becomes "ready" if all authorizations are "valid". // An order becomes "invalid" if any authorization is "invalid". // Status changes: https://tools.ietf.org/html/rfc8555#section-7.1.6 for i, o := range ca.orders { if o.Status != acme.StatusPending { continue } countValid, countInvalid := ca.validateAuthzURLs(o.AuthzURLs, i) if countInvalid > 0 { o.Status = acme.StatusInvalid ca.t.Logf("order %d is now invalid", i) continue } if countValid == len(o.AuthzURLs) { o.Status = acme.StatusReady o.FinalizeURL = ca.serverURL("/new-cert/%d", i) ca.t.Logf("order %d is now ready", i) } } } func (ca *CAServer) validateAuthzURLs(urls []string, orderNum int) (countValid, countInvalid int) { for _, zurl := range urls { z, err := ca.storedAuthz(path.Base(zurl)) if err != nil { ca.t.Logf("no authz %q for order %d", zurl, orderNum) continue } if z.Status == acme.StatusInvalid { countInvalid++ } if z.Status == acme.StatusValid { countValid++ } } return countValid, countInvalid } func (ca *CAServer) verifyALPNChallenge(a *authorization) error { const acmeALPNProto = "acme-tls/1" addr, haveAddr := ca.addr(a.domain) getCert, haveGetCert := ca.getCert(a.domain) if !haveAddr && !haveGetCert { return fmt.Errorf("no resolution information for %q", a.domain) } if haveAddr && haveGetCert { return fmt.Errorf("overlapping resolution information for %q", a.domain) } var crt *x509.Certificate switch { case haveAddr: conn, err := tls.Dial("tcp", addr, &tls.Config{ ServerName: a.domain, InsecureSkipVerify: true, NextProtos: []string{acmeALPNProto}, MinVersion: tls.VersionTLS12, }) if err != nil { return err } if v := conn.ConnectionState().NegotiatedProtocol; v != acmeALPNProto { return fmt.Errorf("CAServer: verifyALPNChallenge: negotiated proto is %q; want %q", v, acmeALPNProto) } if n := len(conn.ConnectionState().PeerCertificates); n != 1 { return fmt.Errorf("len(PeerCertificates) = %d; want 1", n) } crt = conn.ConnectionState().PeerCertificates[0] case haveGetCert: hello := &tls.ClientHelloInfo{ ServerName: a.domain, // TODO: support selecting ECDSA. CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305}, SupportedProtos: []string{acme.ALPNProto}, SupportedVersions: []uint16{tls.VersionTLS12}, } c, err := getCert(hello) if err != nil { return err } crt, err = x509.ParseCertificate(c.Certificate[0]) if err != nil { return err } } if err := crt.VerifyHostname(a.domain); err != nil { return fmt.Errorf("verifyALPNChallenge: VerifyHostname: %v", err) } // See RFC 8737, Section 6.1. oid := asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 1, 31} for _, x := range crt.Extensions { if x.Id.Equal(oid) { // TODO: check the token. return nil } } return fmt.Errorf("verifyTokenCert: no id-pe-acmeIdentifier extension found") } func (ca *CAServer) verifyHTTPChallenge(a *authorization) error { addr, haveAddr := ca.addr(a.domain) handler, haveHandler := ca.getHandler(a.domain) if !haveAddr && !haveHandler { return fmt.Errorf("no resolution information for %q", a.domain) } if haveAddr && haveHandler { return fmt.Errorf("overlapping resolution information for %q", a.domain) } token := challengeToken(a.domain, "http-01", a.id) path := "/.well-known/acme-challenge/" + token var body string switch { case haveAddr: t := &http.Transport{ DialContext: func(ctx context.Context, network, _ string) (net.Conn, error) { return (&net.Dialer{}).DialContext(ctx, network, addr) }, } req, err := http.NewRequest("GET", "http://"+a.domain+path, nil) if err != nil { return err } res, err := t.RoundTrip(req) if err != nil { return err } if res.StatusCode != http.StatusOK { return fmt.Errorf("http token: w.Code = %d; want %d", res.StatusCode, http.StatusOK) } b, err := io.ReadAll(res.Body) if err != nil { return err } body = string(b) case haveHandler: r := httptest.NewRequest("GET", path, nil) r.Host = a.domain w := httptest.NewRecorder() handler.ServeHTTP(w, r) if w.Code != http.StatusOK { return fmt.Errorf("http token: w.Code = %d; want %d", w.Code, http.StatusOK) } body = w.Body.String() } if !strings.HasPrefix(body, token) { return fmt.Errorf("http token value = %q; want 'token-http-01.' prefix", body) } return nil } func decodePayload(v interface{}, r io.Reader) error { var req struct{ Payload string } if err := json.NewDecoder(r).Decode(&req); err != nil { return err } payload, err := base64.RawURLEncoding.DecodeString(req.Payload) if err != nil { return err } return json.Unmarshal(payload, v) } func challengeToken(domain, challType string, authzID int) string { return fmt.Sprintf("token-%s-%s-%d", domain, challType, authzID) } func unique(a []string) []string { seen := make(map[string]bool) var res []string for _, s := range a { if s != "" && !seen[s] { seen[s] = true res = append(res, s) } } return res }
crypto/acme/autocert/internal/acmetest/ca.go/0
{ "file_path": "crypto/acme/autocert/internal/acmetest/ca.go", "repo_id": "crypto", "token_count": 9238 }
0
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build amd64 && gc && !purego package argon2 import "golang.org/x/sys/cpu" func init() { useSSE4 = cpu.X86.HasSSE41 } //go:noescape func mixBlocksSSE2(out, a, b, c *block) //go:noescape func xorBlocksSSE2(out, a, b, c *block) //go:noescape func blamkaSSE4(b *block) func processBlockSSE(out, in1, in2 *block, xor bool) { var t block mixBlocksSSE2(&t, in1, in2, &t) if useSSE4 { blamkaSSE4(&t) } else { for i := 0; i < blockLength; i += 16 { blamkaGeneric( &t[i+0], &t[i+1], &t[i+2], &t[i+3], &t[i+4], &t[i+5], &t[i+6], &t[i+7], &t[i+8], &t[i+9], &t[i+10], &t[i+11], &t[i+12], &t[i+13], &t[i+14], &t[i+15], ) } for i := 0; i < blockLength/8; i += 2 { blamkaGeneric( &t[i], &t[i+1], &t[16+i], &t[16+i+1], &t[32+i], &t[32+i+1], &t[48+i], &t[48+i+1], &t[64+i], &t[64+i+1], &t[80+i], &t[80+i+1], &t[96+i], &t[96+i+1], &t[112+i], &t[112+i+1], ) } } if xor { xorBlocksSSE2(out, in1, in2, &t) } else { mixBlocksSSE2(out, in1, in2, &t) } } func processBlock(out, in1, in2 *block) { processBlockSSE(out, in1, in2, false) } func processBlockXOR(out, in1, in2 *block) { processBlockSSE(out, in1, in2, true) }
crypto/argon2/blamka_amd64.go/0
{ "file_path": "crypto/argon2/blamka_amd64.go", "repo_id": "crypto", "token_count": 729 }
1
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package blake2s implements the BLAKE2s hash algorithm defined by RFC 7693 // and the extendable output function (XOF) BLAKE2Xs. // // BLAKE2s is optimized for 8- to 32-bit platforms and produces digests of any // size between 1 and 32 bytes. // For a detailed specification of BLAKE2s see https://blake2.net/blake2.pdf // and for BLAKE2Xs see https://blake2.net/blake2x.pdf // // If you aren't sure which function you need, use BLAKE2s (Sum256 or New256). // If you need a secret-key MAC (message authentication code), use the New256 // function with a non-nil key. // // BLAKE2X is a construction to compute hash values larger than 32 bytes. It // can produce hash values between 0 and 65535 bytes. package blake2s import ( "crypto" "encoding/binary" "errors" "hash" ) const ( // The blocksize of BLAKE2s in bytes. BlockSize = 64 // The hash size of BLAKE2s-256 in bytes. Size = 32 // The hash size of BLAKE2s-128 in bytes. Size128 = 16 ) var errKeySize = errors.New("blake2s: invalid key size") var iv = [8]uint32{ 0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19, } // Sum256 returns the BLAKE2s-256 checksum of the data. func Sum256(data []byte) [Size]byte { var sum [Size]byte checkSum(&sum, Size, data) return sum } // New256 returns a new hash.Hash computing the BLAKE2s-256 checksum. A non-nil // key turns the hash into a MAC. The key must between zero and 32 bytes long. // When the key is nil, the returned hash.Hash implements BinaryMarshaler // and BinaryUnmarshaler for state (de)serialization as documented by hash.Hash. func New256(key []byte) (hash.Hash, error) { return newDigest(Size, key) } func init() { crypto.RegisterHash(crypto.BLAKE2s_256, func() hash.Hash { h, _ := New256(nil) return h }) } // New128 returns a new hash.Hash computing the BLAKE2s-128 checksum given a // non-empty key. Note that a 128-bit digest is too small to be secure as a // cryptographic hash and should only be used as a MAC, thus the key argument // is not optional. func New128(key []byte) (hash.Hash, error) { if len(key) == 0 { return nil, errors.New("blake2s: a key is required for a 128-bit hash") } return newDigest(Size128, key) } func newDigest(hashSize int, key []byte) (*digest, error) { if len(key) > Size { return nil, errKeySize } d := &digest{ size: hashSize, keyLen: len(key), } copy(d.key[:], key) d.Reset() return d, nil } func checkSum(sum *[Size]byte, hashSize int, data []byte) { var ( h [8]uint32 c [2]uint32 ) h = iv h[0] ^= uint32(hashSize) | (1 << 16) | (1 << 24) if length := len(data); length > BlockSize { n := length &^ (BlockSize - 1) if length == n { n -= BlockSize } hashBlocks(&h, &c, 0, data[:n]) data = data[n:] } var block [BlockSize]byte offset := copy(block[:], data) remaining := uint32(BlockSize - offset) if c[0] < remaining { c[1]-- } c[0] -= remaining hashBlocks(&h, &c, 0xFFFFFFFF, block[:]) for i, v := range h { binary.LittleEndian.PutUint32(sum[4*i:], v) } } type digest struct { h [8]uint32 c [2]uint32 size int block [BlockSize]byte offset int key [BlockSize]byte keyLen int } const ( magic = "b2s" marshaledSize = len(magic) + 8*4 + 2*4 + 1 + BlockSize + 1 ) func (d *digest) MarshalBinary() ([]byte, error) { if d.keyLen != 0 { return nil, errors.New("crypto/blake2s: cannot marshal MACs") } b := make([]byte, 0, marshaledSize) b = append(b, magic...) for i := 0; i < 8; i++ { b = appendUint32(b, d.h[i]) } b = appendUint32(b, d.c[0]) b = appendUint32(b, d.c[1]) // Maximum value for size is 32 b = append(b, byte(d.size)) b = append(b, d.block[:]...) b = append(b, byte(d.offset)) return b, nil } func (d *digest) UnmarshalBinary(b []byte) error { if len(b) < len(magic) || string(b[:len(magic)]) != magic { return errors.New("crypto/blake2s: invalid hash state identifier") } if len(b) != marshaledSize { return errors.New("crypto/blake2s: invalid hash state size") } b = b[len(magic):] for i := 0; i < 8; i++ { b, d.h[i] = consumeUint32(b) } b, d.c[0] = consumeUint32(b) b, d.c[1] = consumeUint32(b) d.size = int(b[0]) b = b[1:] copy(d.block[:], b[:BlockSize]) b = b[BlockSize:] d.offset = int(b[0]) return nil } func (d *digest) BlockSize() int { return BlockSize } func (d *digest) Size() int { return d.size } func (d *digest) Reset() { d.h = iv d.h[0] ^= uint32(d.size) | (uint32(d.keyLen) << 8) | (1 << 16) | (1 << 24) d.offset, d.c[0], d.c[1] = 0, 0, 0 if d.keyLen > 0 { d.block = d.key d.offset = BlockSize } } func (d *digest) Write(p []byte) (n int, err error) { n = len(p) if d.offset > 0 { remaining := BlockSize - d.offset if n <= remaining { d.offset += copy(d.block[d.offset:], p) return } copy(d.block[d.offset:], p[:remaining]) hashBlocks(&d.h, &d.c, 0, d.block[:]) d.offset = 0 p = p[remaining:] } if length := len(p); length > BlockSize { nn := length &^ (BlockSize - 1) if length == nn { nn -= BlockSize } hashBlocks(&d.h, &d.c, 0, p[:nn]) p = p[nn:] } d.offset += copy(d.block[:], p) return } func (d *digest) Sum(sum []byte) []byte { var hash [Size]byte d.finalize(&hash) return append(sum, hash[:d.size]...) } func (d *digest) finalize(hash *[Size]byte) { var block [BlockSize]byte h := d.h c := d.c copy(block[:], d.block[:d.offset]) remaining := uint32(BlockSize - d.offset) if c[0] < remaining { c[1]-- } c[0] -= remaining hashBlocks(&h, &c, 0xFFFFFFFF, block[:]) for i, v := range h { binary.LittleEndian.PutUint32(hash[4*i:], v) } } func appendUint32(b []byte, x uint32) []byte { var a [4]byte binary.BigEndian.PutUint32(a[:], x) return append(b, a[:]...) } func consumeUint32(b []byte) ([]byte, uint32) { x := binary.BigEndian.Uint32(b) return b[4:], x }
crypto/blake2s/blake2s.go/0
{ "file_path": "crypto/blake2s/blake2s.go", "repo_id": "crypto", "token_count": 2521 }
2
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bn256 import ( "math/big" ) // curvePoint implements the elliptic curve y²=x³+3. Points are kept in // Jacobian form and t=z² when valid. G₁ is the set of points of this curve on // GF(p). type curvePoint struct { x, y, z, t *big.Int } var curveB = new(big.Int).SetInt64(3) // curveGen is the generator of G₁. var curveGen = &curvePoint{ new(big.Int).SetInt64(1), new(big.Int).SetInt64(-2), new(big.Int).SetInt64(1), new(big.Int).SetInt64(1), } func newCurvePoint(pool *bnPool) *curvePoint { return &curvePoint{ pool.Get(), pool.Get(), pool.Get(), pool.Get(), } } func (c *curvePoint) String() string { c.MakeAffine(new(bnPool)) return "(" + c.x.String() + ", " + c.y.String() + ")" } func (c *curvePoint) Put(pool *bnPool) { pool.Put(c.x) pool.Put(c.y) pool.Put(c.z) pool.Put(c.t) } func (c *curvePoint) Set(a *curvePoint) { c.x.Set(a.x) c.y.Set(a.y) c.z.Set(a.z) c.t.Set(a.t) } // IsOnCurve returns true iff c is on the curve where c must be in affine form. func (c *curvePoint) IsOnCurve() bool { yy := new(big.Int).Mul(c.y, c.y) xxx := new(big.Int).Mul(c.x, c.x) xxx.Mul(xxx, c.x) yy.Sub(yy, xxx) yy.Sub(yy, curveB) if yy.Sign() < 0 || yy.Cmp(p) >= 0 { yy.Mod(yy, p) } return yy.Sign() == 0 } func (c *curvePoint) SetInfinity() { c.z.SetInt64(0) } func (c *curvePoint) IsInfinity() bool { return c.z.Sign() == 0 } func (c *curvePoint) Add(a, b *curvePoint, pool *bnPool) { if a.IsInfinity() { c.Set(b) return } if b.IsInfinity() { c.Set(a) return } // See http://hyperelliptic.org/EFD/g1p/auto-code/shortw/jacobian-0/addition/add-2007-bl.op3 // Normalize the points by replacing a = [x1:y1:z1] and b = [x2:y2:z2] // by [u1:s1:z1·z2] and [u2:s2:z1·z2] // where u1 = x1·z2², s1 = y1·z2³ and u1 = x2·z1², s2 = y2·z1³ z1z1 := pool.Get().Mul(a.z, a.z) z1z1.Mod(z1z1, p) z2z2 := pool.Get().Mul(b.z, b.z) z2z2.Mod(z2z2, p) u1 := pool.Get().Mul(a.x, z2z2) u1.Mod(u1, p) u2 := pool.Get().Mul(b.x, z1z1) u2.Mod(u2, p) t := pool.Get().Mul(b.z, z2z2) t.Mod(t, p) s1 := pool.Get().Mul(a.y, t) s1.Mod(s1, p) t.Mul(a.z, z1z1) t.Mod(t, p) s2 := pool.Get().Mul(b.y, t) s2.Mod(s2, p) // Compute x = (2h)²(s²-u1-u2) // where s = (s2-s1)/(u2-u1) is the slope of the line through // (u1,s1) and (u2,s2). The extra factor 2h = 2(u2-u1) comes from the value of z below. // This is also: // 4(s2-s1)² - 4h²(u1+u2) = 4(s2-s1)² - 4h³ - 4h²(2u1) // = r² - j - 2v // with the notations below. h := pool.Get().Sub(u2, u1) xEqual := h.Sign() == 0 t.Add(h, h) // i = 4h² i := pool.Get().Mul(t, t) i.Mod(i, p) // j = 4h³ j := pool.Get().Mul(h, i) j.Mod(j, p) t.Sub(s2, s1) yEqual := t.Sign() == 0 if xEqual && yEqual { c.Double(a, pool) return } r := pool.Get().Add(t, t) v := pool.Get().Mul(u1, i) v.Mod(v, p) // t4 = 4(s2-s1)² t4 := pool.Get().Mul(r, r) t4.Mod(t4, p) t.Add(v, v) t6 := pool.Get().Sub(t4, j) c.x.Sub(t6, t) // Set y = -(2h)³(s1 + s*(x/4h²-u1)) // This is also // y = - 2·s1·j - (s2-s1)(2x - 2i·u1) = r(v-x) - 2·s1·j t.Sub(v, c.x) // t7 t4.Mul(s1, j) // t8 t4.Mod(t4, p) t6.Add(t4, t4) // t9 t4.Mul(r, t) // t10 t4.Mod(t4, p) c.y.Sub(t4, t6) // Set z = 2(u2-u1)·z1·z2 = 2h·z1·z2 t.Add(a.z, b.z) // t11 t4.Mul(t, t) // t12 t4.Mod(t4, p) t.Sub(t4, z1z1) // t13 t4.Sub(t, z2z2) // t14 c.z.Mul(t4, h) c.z.Mod(c.z, p) pool.Put(z1z1) pool.Put(z2z2) pool.Put(u1) pool.Put(u2) pool.Put(t) pool.Put(s1) pool.Put(s2) pool.Put(h) pool.Put(i) pool.Put(j) pool.Put(r) pool.Put(v) pool.Put(t4) pool.Put(t6) } func (c *curvePoint) Double(a *curvePoint, pool *bnPool) { // See http://hyperelliptic.org/EFD/g1p/auto-code/shortw/jacobian-0/doubling/dbl-2009-l.op3 A := pool.Get().Mul(a.x, a.x) A.Mod(A, p) B := pool.Get().Mul(a.y, a.y) B.Mod(B, p) C := pool.Get().Mul(B, B) C.Mod(C, p) t := pool.Get().Add(a.x, B) t2 := pool.Get().Mul(t, t) t2.Mod(t2, p) t.Sub(t2, A) t2.Sub(t, C) d := pool.Get().Add(t2, t2) t.Add(A, A) e := pool.Get().Add(t, A) f := pool.Get().Mul(e, e) f.Mod(f, p) t.Add(d, d) c.x.Sub(f, t) t.Add(C, C) t2.Add(t, t) t.Add(t2, t2) c.y.Sub(d, c.x) t2.Mul(e, c.y) t2.Mod(t2, p) c.y.Sub(t2, t) t.Mul(a.y, a.z) t.Mod(t, p) c.z.Add(t, t) pool.Put(A) pool.Put(B) pool.Put(C) pool.Put(t) pool.Put(t2) pool.Put(d) pool.Put(e) pool.Put(f) } func (c *curvePoint) Mul(a *curvePoint, scalar *big.Int, pool *bnPool) *curvePoint { sum := newCurvePoint(pool) sum.SetInfinity() t := newCurvePoint(pool) for i := scalar.BitLen(); i >= 0; i-- { t.Double(sum, pool) if scalar.Bit(i) != 0 { sum.Add(t, a, pool) } else { sum.Set(t) } } c.Set(sum) sum.Put(pool) t.Put(pool) return c } // MakeAffine converts c to affine form and returns c. If c is ∞, then it sets // c to 0 : 1 : 0. func (c *curvePoint) MakeAffine(pool *bnPool) *curvePoint { if words := c.z.Bits(); len(words) == 1 && words[0] == 1 { return c } if c.IsInfinity() { c.x.SetInt64(0) c.y.SetInt64(1) c.z.SetInt64(0) c.t.SetInt64(0) return c } zInv := pool.Get().ModInverse(c.z, p) t := pool.Get().Mul(c.y, zInv) t.Mod(t, p) zInv2 := pool.Get().Mul(zInv, zInv) zInv2.Mod(zInv2, p) c.y.Mul(t, zInv2) c.y.Mod(c.y, p) t.Mul(c.x, zInv2) t.Mod(t, p) c.x.Set(t) c.z.SetInt64(1) c.t.SetInt64(1) pool.Put(zInv) pool.Put(t) pool.Put(zInv2) return c } func (c *curvePoint) Negative(a *curvePoint) { c.x.Set(a.x) c.y.Neg(a.y) c.z.Set(a.z) c.t.SetInt64(0) }
crypto/bn256/curve.go/0
{ "file_path": "crypto/bn256/curve.go", "repo_id": "crypto", "token_count": 3206 }
3
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build gc && !purego #include "go_asm.h" #include "textflag.h" // This is an implementation of the ChaCha20 encryption algorithm as // specified in RFC 7539. It uses vector instructions to compute // 4 keystream blocks in parallel (256 bytes) which are then XORed // with the bytes in the input slice. GLOBL ·constants<>(SB), RODATA|NOPTR, $32 // BSWAP: swap bytes in each 4-byte element DATA ·constants<>+0x00(SB)/4, $0x03020100 DATA ·constants<>+0x04(SB)/4, $0x07060504 DATA ·constants<>+0x08(SB)/4, $0x0b0a0908 DATA ·constants<>+0x0c(SB)/4, $0x0f0e0d0c // J0: [j0, j1, j2, j3] DATA ·constants<>+0x10(SB)/4, $0x61707865 DATA ·constants<>+0x14(SB)/4, $0x3320646e DATA ·constants<>+0x18(SB)/4, $0x79622d32 DATA ·constants<>+0x1c(SB)/4, $0x6b206574 #define BSWAP V5 #define J0 V6 #define KEY0 V7 #define KEY1 V8 #define NONCE V9 #define CTR V10 #define M0 V11 #define M1 V12 #define M2 V13 #define M3 V14 #define INC V15 #define X0 V16 #define X1 V17 #define X2 V18 #define X3 V19 #define X4 V20 #define X5 V21 #define X6 V22 #define X7 V23 #define X8 V24 #define X9 V25 #define X10 V26 #define X11 V27 #define X12 V28 #define X13 V29 #define X14 V30 #define X15 V31 #define NUM_ROUNDS 20 #define ROUND4(a0, a1, a2, a3, b0, b1, b2, b3, c0, c1, c2, c3, d0, d1, d2, d3) \ VAF a1, a0, a0 \ VAF b1, b0, b0 \ VAF c1, c0, c0 \ VAF d1, d0, d0 \ VX a0, a2, a2 \ VX b0, b2, b2 \ VX c0, c2, c2 \ VX d0, d2, d2 \ VERLLF $16, a2, a2 \ VERLLF $16, b2, b2 \ VERLLF $16, c2, c2 \ VERLLF $16, d2, d2 \ VAF a2, a3, a3 \ VAF b2, b3, b3 \ VAF c2, c3, c3 \ VAF d2, d3, d3 \ VX a3, a1, a1 \ VX b3, b1, b1 \ VX c3, c1, c1 \ VX d3, d1, d1 \ VERLLF $12, a1, a1 \ VERLLF $12, b1, b1 \ VERLLF $12, c1, c1 \ VERLLF $12, d1, d1 \ VAF a1, a0, a0 \ VAF b1, b0, b0 \ VAF c1, c0, c0 \ VAF d1, d0, d0 \ VX a0, a2, a2 \ VX b0, b2, b2 \ VX c0, c2, c2 \ VX d0, d2, d2 \ VERLLF $8, a2, a2 \ VERLLF $8, b2, b2 \ VERLLF $8, c2, c2 \ VERLLF $8, d2, d2 \ VAF a2, a3, a3 \ VAF b2, b3, b3 \ VAF c2, c3, c3 \ VAF d2, d3, d3 \ VX a3, a1, a1 \ VX b3, b1, b1 \ VX c3, c1, c1 \ VX d3, d1, d1 \ VERLLF $7, a1, a1 \ VERLLF $7, b1, b1 \ VERLLF $7, c1, c1 \ VERLLF $7, d1, d1 #define PERMUTE(mask, v0, v1, v2, v3) \ VPERM v0, v0, mask, v0 \ VPERM v1, v1, mask, v1 \ VPERM v2, v2, mask, v2 \ VPERM v3, v3, mask, v3 #define ADDV(x, v0, v1, v2, v3) \ VAF x, v0, v0 \ VAF x, v1, v1 \ VAF x, v2, v2 \ VAF x, v3, v3 #define XORV(off, dst, src, v0, v1, v2, v3) \ VLM off(src), M0, M3 \ PERMUTE(BSWAP, v0, v1, v2, v3) \ VX v0, M0, M0 \ VX v1, M1, M1 \ VX v2, M2, M2 \ VX v3, M3, M3 \ VSTM M0, M3, off(dst) #define SHUFFLE(a, b, c, d, t, u, v, w) \ VMRHF a, c, t \ // t = {a[0], c[0], a[1], c[1]} VMRHF b, d, u \ // u = {b[0], d[0], b[1], d[1]} VMRLF a, c, v \ // v = {a[2], c[2], a[3], c[3]} VMRLF b, d, w \ // w = {b[2], d[2], b[3], d[3]} VMRHF t, u, a \ // a = {a[0], b[0], c[0], d[0]} VMRLF t, u, b \ // b = {a[1], b[1], c[1], d[1]} VMRHF v, w, c \ // c = {a[2], b[2], c[2], d[2]} VMRLF v, w, d // d = {a[3], b[3], c[3], d[3]} // func xorKeyStreamVX(dst, src []byte, key *[8]uint32, nonce *[3]uint32, counter *uint32) TEXT ·xorKeyStreamVX(SB), NOSPLIT, $0 MOVD $·constants<>(SB), R1 MOVD dst+0(FP), R2 // R2=&dst[0] LMG src+24(FP), R3, R4 // R3=&src[0] R4=len(src) MOVD key+48(FP), R5 // R5=key MOVD nonce+56(FP), R6 // R6=nonce MOVD counter+64(FP), R7 // R7=counter // load BSWAP and J0 VLM (R1), BSWAP, J0 // setup MOVD $95, R0 VLM (R5), KEY0, KEY1 VLL R0, (R6), NONCE VZERO M0 VLEIB $7, $32, M0 VSRLB M0, NONCE, NONCE // initialize counter values VLREPF (R7), CTR VZERO INC VLEIF $1, $1, INC VLEIF $2, $2, INC VLEIF $3, $3, INC VAF INC, CTR, CTR VREPIF $4, INC chacha: VREPF $0, J0, X0 VREPF $1, J0, X1 VREPF $2, J0, X2 VREPF $3, J0, X3 VREPF $0, KEY0, X4 VREPF $1, KEY0, X5 VREPF $2, KEY0, X6 VREPF $3, KEY0, X7 VREPF $0, KEY1, X8 VREPF $1, KEY1, X9 VREPF $2, KEY1, X10 VREPF $3, KEY1, X11 VLR CTR, X12 VREPF $1, NONCE, X13 VREPF $2, NONCE, X14 VREPF $3, NONCE, X15 MOVD $(NUM_ROUNDS/2), R1 loop: ROUND4(X0, X4, X12, X8, X1, X5, X13, X9, X2, X6, X14, X10, X3, X7, X15, X11) ROUND4(X0, X5, X15, X10, X1, X6, X12, X11, X2, X7, X13, X8, X3, X4, X14, X9) ADD $-1, R1 BNE loop // decrement length ADD $-256, R4 // rearrange vectors SHUFFLE(X0, X1, X2, X3, M0, M1, M2, M3) ADDV(J0, X0, X1, X2, X3) SHUFFLE(X4, X5, X6, X7, M0, M1, M2, M3) ADDV(KEY0, X4, X5, X6, X7) SHUFFLE(X8, X9, X10, X11, M0, M1, M2, M3) ADDV(KEY1, X8, X9, X10, X11) VAF CTR, X12, X12 SHUFFLE(X12, X13, X14, X15, M0, M1, M2, M3) ADDV(NONCE, X12, X13, X14, X15) // increment counters VAF INC, CTR, CTR // xor keystream with plaintext XORV(0*64, R2, R3, X0, X4, X8, X12) XORV(1*64, R2, R3, X1, X5, X9, X13) XORV(2*64, R2, R3, X2, X6, X10, X14) XORV(3*64, R2, R3, X3, X7, X11, X15) // increment pointers MOVD $256(R2), R2 MOVD $256(R3), R3 CMPBNE R4, $0, chacha VSTEF $0, CTR, (R7) RET
crypto/chacha20/chacha_s390x.s/0
{ "file_path": "crypto/chacha20/chacha_s390x.s", "repo_id": "crypto", "token_count": 3306 }
4
// Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package wycheproof import ( "bytes" "crypto/aes" "crypto/cipher" "fmt" "testing" "golang.org/x/crypto/chacha20poly1305" ) func TestAEAD(t *testing.T) { // AeadTestVector type AeadTestVector struct { // additional authenticated data Aad string `json:"aad,omitempty"` // A brief description of the test case Comment string `json:"comment,omitempty"` // the ciphertext (without iv and tag) Ct string `json:"ct,omitempty"` // A list of flags Flags []string `json:"flags,omitempty"` // the nonce Iv string `json:"iv,omitempty"` // the key Key string `json:"key,omitempty"` // the plaintext Msg string `json:"msg,omitempty"` // Test result Result string `json:"result,omitempty"` // the authentication tag Tag string `json:"tag,omitempty"` // Identifier of the test case TcId int `json:"tcId,omitempty"` } // Notes a description of the labels used in the test vectors type Notes struct { } // AeadTestGroup type AeadTestGroup struct { // the IV size in bits IvSize int `json:"ivSize,omitempty"` // the keySize in bits KeySize int `json:"keySize,omitempty"` // the expected size of the tag in bits TagSize int `json:"tagSize,omitempty"` Tests []*AeadTestVector `json:"tests,omitempty"` Type interface{} `json:"type,omitempty"` } // Root type Root struct { // the primitive tested in the test file Algorithm string `json:"algorithm,omitempty"` // the version of the test vectors. GeneratorVersion string `json:"generatorVersion,omitempty"` // additional documentation Header []string `json:"header,omitempty"` // a description of the labels used in the test vectors Notes *Notes `json:"notes,omitempty"` // the number of test vectors in this test NumberOfTests int `json:"numberOfTests,omitempty"` Schema interface{} `json:"schema,omitempty"` TestGroups []*AeadTestGroup `json:"testGroups,omitempty"` } testSealOpen := func(t *testing.T, aead cipher.AEAD, tv *AeadTestVector, recoverBadNonce func()) { defer recoverBadNonce() iv, tag, ct, msg, aad := decodeHex(tv.Iv), decodeHex(tv.Tag), decodeHex(tv.Ct), decodeHex(tv.Msg), decodeHex(tv.Aad) genCT := aead.Seal(nil, iv, msg, aad) genMsg, err := aead.Open(nil, iv, genCT, aad) if err != nil { t.Errorf("failed to decrypt generated ciphertext: %s", err) } if !bytes.Equal(genMsg, msg) { t.Errorf("unexpected roundtripped plaintext: got %x, want %x", genMsg, msg) } ctWithTag := append(ct, tag...) msg2, err := aead.Open(nil, iv, ctWithTag, aad) wantPass := shouldPass(tv.Result, tv.Flags, nil) if !wantPass && err == nil { t.Error("decryption succeeded when it should've failed") } else if wantPass { if err != nil { t.Fatalf("decryption failed: %s", err) } if !bytes.Equal(genCT, ctWithTag) { t.Errorf("generated ciphertext doesn't match expected: got %x, want %x", genCT, ctWithTag) } if !bytes.Equal(msg, msg2) { t.Errorf("decrypted ciphertext doesn't match expected: got %x, want %x", msg2, msg) } } } vectors := map[string]func(*testing.T, []byte) cipher.AEAD{ "aes_gcm_test.json": func(t *testing.T, key []byte) cipher.AEAD { aesCipher, err := aes.NewCipher(key) if err != nil { t.Fatalf("failed to construct cipher: %s", err) } aead, err := cipher.NewGCM(aesCipher) if err != nil { t.Fatalf("failed to construct cipher: %s", err) } return aead }, "chacha20_poly1305_test.json": func(t *testing.T, key []byte) cipher.AEAD { aead, err := chacha20poly1305.New(key) if err != nil { t.Fatalf("failed to construct cipher: %s", err) } return aead }, "xchacha20_poly1305_test.json": func(t *testing.T, key []byte) cipher.AEAD { aead, err := chacha20poly1305.NewX(key) if err != nil { t.Fatalf("failed to construct cipher: %s", err) } return aead }, } for file, cipherInit := range vectors { var root Root readTestVector(t, file, &root) for _, tg := range root.TestGroups { for _, tv := range tg.Tests { testName := fmt.Sprintf("%s #%d", file, tv.TcId) if tv.Comment != "" { testName += fmt.Sprintf(" %s", tv.Comment) } t.Run(testName, func(t *testing.T) { aead := cipherInit(t, decodeHex(tv.Key)) testSealOpen(t, aead, tv, func() { // A bad nonce causes a panic in AEAD.Seal and AEAD.Open, // so should be recovered. Fail the test if it broke for // some other reason. if r := recover(); r != nil { if tg.IvSize/8 == aead.NonceSize() { t.Error("unexpected panic") } } }) }) } } } }
crypto/internal/wycheproof/aead_test.go/0
{ "file_path": "crypto/internal/wycheproof/aead_test.go", "repo_id": "crypto", "token_count": 1997 }
5
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ocsp import ( "bytes" "crypto" "crypto/rand" "crypto/rsa" "crypto/sha1" "crypto/x509" "crypto/x509/pkix" "encoding/asn1" "encoding/hex" "encoding/pem" "math/big" "reflect" "testing" "time" ) func TestOCSPDecode(t *testing.T) { responseBytes, _ := hex.DecodeString(ocspResponseHex) resp, err := ParseResponse(responseBytes, nil) if err != nil { t.Fatal(err) } // keyHash is the SKID of the issuer of the certificate the OCSP // response is for. keyHash, err := hex.DecodeString("8a747faf85cdee95cd3d9cd0e24614f371351d27") if err != nil { t.Fatal(err) } // serialBytes is the serial number of the certificate the OCSP // response is for. serialBytes, err := hex.DecodeString("f374542e3c7a68360a00000001103462") if err != nil { t.Fatal(err) } expected := Response{ Status: Good, SerialNumber: big.NewInt(0).SetBytes(serialBytes), RevocationReason: Unspecified, ThisUpdate: time.Date(2021, 11, 7, 14, 25, 51, 0, time.UTC), NextUpdate: time.Date(2021, 11, 14, 13, 25, 50, 0, time.UTC), ResponderKeyHash: keyHash, } if !reflect.DeepEqual(resp.ThisUpdate, expected.ThisUpdate) { t.Errorf("resp.ThisUpdate: got %v, want %v", resp.ThisUpdate, expected.ThisUpdate) } if !reflect.DeepEqual(resp.NextUpdate, expected.NextUpdate) { t.Errorf("resp.NextUpdate: got %v, want %v", resp.NextUpdate, expected.NextUpdate) } if resp.Status != expected.Status { t.Errorf("resp.Status: got %d, want %d", resp.Status, expected.Status) } if resp.SerialNumber.Cmp(expected.SerialNumber) != 0 { t.Errorf("resp.SerialNumber: got %x, want %x", resp.SerialNumber, expected.SerialNumber) } if resp.RevocationReason != expected.RevocationReason { t.Errorf("resp.RevocationReason: got %d, want %d", resp.RevocationReason, expected.RevocationReason) } if !bytes.Equal(resp.RawResponderName, expected.RawResponderName) { t.Errorf("resp.RawResponderName: got %x, want %x", resp.RawResponderName, expected.RawResponderName) } if !bytes.Equal(resp.ResponderKeyHash, expected.ResponderKeyHash) { t.Errorf("resp.ResponderKeyHash: got %x, want %x", resp.ResponderKeyHash, expected.ResponderKeyHash) } } func TestOCSPDecodeWithoutCert(t *testing.T) { responseBytes, _ := hex.DecodeString(ocspResponseWithoutCertHex) _, err := ParseResponse(responseBytes, nil) if err != nil { t.Error(err) } } func TestOCSPDecodeWithExtensions(t *testing.T) { responseBytes, _ := hex.DecodeString(ocspResponseWithCriticalExtensionHex) _, err := ParseResponse(responseBytes, nil) if err == nil { t.Error(err) } responseBytes, _ = hex.DecodeString(ocspResponseWithExtensionHex) response, err := ParseResponse(responseBytes, nil) if err != nil { t.Fatal(err) } if len(response.Extensions) != 1 { t.Errorf("len(response.Extensions): got %v, want %v", len(response.Extensions), 1) } extensionBytes := response.Extensions[0].Value expectedBytes, _ := hex.DecodeString(ocspExtensionValueHex) if !bytes.Equal(extensionBytes, expectedBytes) { t.Errorf("response.Extensions[0]: got %x, want %x", extensionBytes, expectedBytes) } } func TestOCSPSignature(t *testing.T) { b, _ := pem.Decode([]byte(GTSRoot)) issuer, err := x509.ParseCertificate(b.Bytes) if err != nil { t.Fatal(err) } response, _ := hex.DecodeString(ocspResponseHex) if _, err := ParseResponse(response, issuer); err != nil { t.Error(err) } } func TestOCSPRequest(t *testing.T) { leafCert, _ := hex.DecodeString(leafCertHex) cert, err := x509.ParseCertificate(leafCert) if err != nil { t.Fatal(err) } issuerCert, _ := hex.DecodeString(issuerCertHex) issuer, err := x509.ParseCertificate(issuerCert) if err != nil { t.Fatal(err) } request, err := CreateRequest(cert, issuer, nil) if err != nil { t.Fatal(err) } expectedBytes, _ := hex.DecodeString(ocspRequestHex) if !bytes.Equal(request, expectedBytes) { t.Errorf("request: got %x, wanted %x", request, expectedBytes) } decodedRequest, err := ParseRequest(expectedBytes) if err != nil { t.Fatal(err) } if decodedRequest.HashAlgorithm != crypto.SHA1 { t.Errorf("request.HashAlgorithm: got %v, want %v", decodedRequest.HashAlgorithm, crypto.SHA1) } var publicKeyInfo struct { Algorithm pkix.AlgorithmIdentifier PublicKey asn1.BitString } _, err = asn1.Unmarshal(issuer.RawSubjectPublicKeyInfo, &publicKeyInfo) if err != nil { t.Fatal(err) } h := sha1.New() h.Write(publicKeyInfo.PublicKey.RightAlign()) issuerKeyHash := h.Sum(nil) h.Reset() h.Write(issuer.RawSubject) issuerNameHash := h.Sum(nil) if got := decodedRequest.IssuerKeyHash; !bytes.Equal(got, issuerKeyHash) { t.Errorf("request.IssuerKeyHash: got %x, want %x", got, issuerKeyHash) } if got := decodedRequest.IssuerNameHash; !bytes.Equal(got, issuerNameHash) { t.Errorf("request.IssuerKeyHash: got %x, want %x", got, issuerNameHash) } if got := decodedRequest.SerialNumber; got.Cmp(cert.SerialNumber) != 0 { t.Errorf("request.SerialNumber: got %x, want %x", got, cert.SerialNumber) } marshaledRequest, err := decodedRequest.Marshal() if err != nil { t.Fatal(err) } if bytes.Compare(expectedBytes, marshaledRequest) != 0 { t.Errorf( "Marshaled request doesn't match expected: wanted %x, got %x", expectedBytes, marshaledRequest, ) } } func TestOCSPResponse(t *testing.T) { leafCert, _ := hex.DecodeString(leafCertHex) leaf, err := x509.ParseCertificate(leafCert) if err != nil { t.Fatal(err) } issuerCert, _ := hex.DecodeString(issuerCertHex) issuer, err := x509.ParseCertificate(issuerCert) if err != nil { t.Fatal(err) } responderCert, _ := hex.DecodeString(responderCertHex) responder, err := x509.ParseCertificate(responderCert) if err != nil { t.Fatal(err) } responderPrivateKeyDER, _ := hex.DecodeString(responderPrivateKeyHex) responderPrivateKey, err := x509.ParsePKCS1PrivateKey(responderPrivateKeyDER) if err != nil { t.Fatal(err) } extensionBytes, _ := hex.DecodeString(ocspExtensionValueHex) extensions := []pkix.Extension{ { Id: ocspExtensionOID, Critical: false, Value: extensionBytes, }, } thisUpdate := time.Date(2010, 7, 7, 15, 1, 5, 0, time.UTC) nextUpdate := time.Date(2010, 7, 7, 18, 35, 17, 0, time.UTC) template := Response{ Status: Revoked, SerialNumber: leaf.SerialNumber, ThisUpdate: thisUpdate, NextUpdate: nextUpdate, RevokedAt: thisUpdate, RevocationReason: KeyCompromise, Certificate: responder, ExtraExtensions: extensions, } template.IssuerHash = crypto.MD5 _, err = CreateResponse(issuer, responder, template, responderPrivateKey) if err == nil { t.Fatal("CreateResponse didn't fail with non-valid template.IssuerHash value crypto.MD5") } testCases := []struct { name string issuerHash crypto.Hash }{ {"Zero value", 0}, {"crypto.SHA1", crypto.SHA1}, {"crypto.SHA256", crypto.SHA256}, {"crypto.SHA384", crypto.SHA384}, {"crypto.SHA512", crypto.SHA512}, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { template.IssuerHash = tc.issuerHash responseBytes, err := CreateResponse(issuer, responder, template, responderPrivateKey) if err != nil { t.Fatalf("CreateResponse failed: %s", err) } resp, err := ParseResponse(responseBytes, nil) if err != nil { t.Fatalf("ParseResponse failed: %s", err) } if !reflect.DeepEqual(resp.ThisUpdate, template.ThisUpdate) { t.Errorf("resp.ThisUpdate: got %v, want %v", resp.ThisUpdate, template.ThisUpdate) } if !reflect.DeepEqual(resp.NextUpdate, template.NextUpdate) { t.Errorf("resp.NextUpdate: got %v, want %v", resp.NextUpdate, template.NextUpdate) } if !reflect.DeepEqual(resp.RevokedAt, template.RevokedAt) { t.Errorf("resp.RevokedAt: got %v, want %v", resp.RevokedAt, template.RevokedAt) } if !reflect.DeepEqual(resp.Extensions, template.ExtraExtensions) { t.Errorf("resp.Extensions: got %v, want %v", resp.Extensions, template.ExtraExtensions) } delay := time.Since(resp.ProducedAt) if delay < -time.Hour || delay > time.Hour { t.Errorf("resp.ProducedAt: got %s, want close to current time (%s)", resp.ProducedAt, time.Now()) } if resp.Status != template.Status { t.Errorf("resp.Status: got %d, want %d", resp.Status, template.Status) } if resp.SerialNumber.Cmp(template.SerialNumber) != 0 { t.Errorf("resp.SerialNumber: got %x, want %x", resp.SerialNumber, template.SerialNumber) } if resp.RevocationReason != template.RevocationReason { t.Errorf("resp.RevocationReason: got %d, want %d", resp.RevocationReason, template.RevocationReason) } expectedHash := tc.issuerHash if tc.issuerHash == 0 { expectedHash = crypto.SHA1 } if resp.IssuerHash != expectedHash { t.Errorf("resp.IssuerHash: got %d, want %d", resp.IssuerHash, expectedHash) } }) } } func TestErrorResponse(t *testing.T) { responseBytes, _ := hex.DecodeString(errorResponseHex) _, err := ParseResponse(responseBytes, nil) respErr, ok := err.(ResponseError) if !ok { t.Fatalf("expected ResponseError from ParseResponse but got %#v", err) } if respErr.Status != Malformed { t.Fatalf("expected Malformed status from ParseResponse but got %d", respErr.Status) } } func createMultiResp() ([]byte, error) { rawResponderID := asn1.RawValue{ Class: 2, // context-specific Tag: 1, // Name (explicit tag) IsCompound: true, Bytes: []byte{48, 0}, } tbsResponseData := responseData{ Version: 0, RawResponderID: rawResponderID, ProducedAt: time.Now().Truncate(time.Minute).UTC(), } this := time.Now() next := this.Add(time.Hour * 24 * 4) for i := int64(0); i < 5; i++ { tbsResponseData.Responses = append(tbsResponseData.Responses, singleResponse{ CertID: certID{ HashAlgorithm: pkix.AlgorithmIdentifier{ Algorithm: hashOIDs[crypto.SHA1], Parameters: asn1.RawValue{Tag: 5 /* ASN.1 NULL */}, }, NameHash: []byte{1, 2, 3}, IssuerKeyHash: []byte{4, 5, 6}, SerialNumber: big.NewInt(i), }, ThisUpdate: this.UTC(), NextUpdate: next.UTC(), Good: true, }) } tbsResponseDataDER, err := asn1.Marshal(tbsResponseData) if err != nil { return nil, err } k, err := rsa.GenerateKey(rand.Reader, 1024) if err != nil { return nil, err } hashFunc, signatureAlgorithm, err := signingParamsForPublicKey(k.Public(), x509.SHA1WithRSA) if err != nil { return nil, err } responseHash := hashFunc.New() responseHash.Write(tbsResponseDataDER) signature, err := k.Sign(rand.Reader, responseHash.Sum(nil), hashFunc) if err != nil { return nil, err } response := basicResponse{ TBSResponseData: tbsResponseData, SignatureAlgorithm: signatureAlgorithm, Signature: asn1.BitString{ Bytes: signature, BitLength: 8 * len(signature), }, } responseDER, err := asn1.Marshal(response) if err != nil { return nil, err } return asn1.Marshal(responseASN1{ Status: asn1.Enumerated(Success), Response: responseBytes{ ResponseType: idPKIXOCSPBasic, Response: responseDER, }, }) } func TestOCSPDecodeMultiResponse(t *testing.T) { respBytes, err := createMultiResp() if err != nil { t.Fatal(err) } matchingCert := &x509.Certificate{SerialNumber: big.NewInt(3)} resp, err := ParseResponseForCert(respBytes, matchingCert, nil) if err != nil { t.Fatal(err) } if resp.SerialNumber.Cmp(matchingCert.SerialNumber) != 0 { t.Errorf("resp.SerialNumber: got %x, want %x", resp.SerialNumber, 3) } } func TestOCSPDecodeMultiResponseWithoutMatchingCert(t *testing.T) { respBytes, err := createMultiResp() if err != nil { t.Fatal(err) } _, err = ParseResponseForCert(respBytes, &x509.Certificate{SerialNumber: big.NewInt(100)}, nil) want := ParseError("no response matching the supplied certificate") if err != want { t.Errorf("err: got %q, want %q", err, want) } } // This OCSP response was taken from GTS's public OCSP responder. // To recreate: // $ openssl s_client -tls1 -showcerts -servername golang.org -connect golang.org:443 // Copy and paste the first certificate into /tmp/cert.crt and the second into // /tmp/intermediate.crt // Note: depending on what version of openssl you are using, you may need to use the key=value // form for the header argument (i.e. -header host=ocsp.pki.goog) // $ openssl ocsp -issuer /tmp/intermediate.crt -cert /tmp/cert.crt -url http://ocsp.pki.goog/gts1c3 -header host ocsp.pki.goog -resp_text -respout /tmp/ocsp.der // Then hex encode the result: // $ python -c 'print file("/tmp/ocsp.der", "r").read().encode("hex")' const ocspResponseHex = "308201d40a0100a08201cd308201c906092b0601050507300101048201ba308201b630819fa21604148a747faf85cdee95cd3d9cd0e24614f371351d27180f32303231313130373134323535335a30743072304a300906052b0e03021a05000414c72e798addff6134b3baed4742b8bbc6c024076304148a747faf85cdee95cd3d9cd0e24614f371351d27021100f374542e3c7a68360a000000011034628000180f32303231313130373134323535315aa011180f32303231313131343133323535305a300d06092a864886f70d01010b0500038201010087749296e681abe36f2efef047730178ce57e948426959ac62ac5f25b9a63ba3b7f31b9f683aea384d21845c8dda09498f2531c78f3add3969ca4092f31f58ac3c2613719d63b7b9a5260e52814c827f8dd44f4f753b2528bcd03ccec02cdcd4918247f5323f8cfc12cee4ac8f0361587b267019cfd12336db09b04eac59807a480213cfcd9913a3aa2d13a6c88c0a750475a0e991806d94ec0fc9dab599171a43a08e6d935b4a4a13dff9c4a97ad46cef6fb4d61cb2363d788c12d81cce851b478889c2e05d80cd00ae346772a1e7502f011e2ed9be8ef4b194c8b65d6e33671d878cfb30267972075b062ff3d56b51984bf685161afc6e2538dd6e6a23063c" const GTSRoot = `-----BEGIN CERTIFICATE----- MIIFljCCA36gAwIBAgINAgO8U1lrNMcY9QFQZjANBgkqhkiG9w0BAQsFADBHMQsw CQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEU MBIGA1UEAxMLR1RTIFJvb3QgUjEwHhcNMjAwODEzMDAwMDQyWhcNMjcwOTMwMDAw MDQyWjBGMQswCQYDVQQGEwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZp Y2VzIExMQzETMBEGA1UEAxMKR1RTIENBIDFDMzCCASIwDQYJKoZIhvcNAQEBBQAD ggEPADCCAQoCggEBAPWI3+dijB43+DdCkH9sh9D7ZYIl/ejLa6T/belaI+KZ9hzp kgOZE3wJCor6QtZeViSqejOEH9Hpabu5dOxXTGZok3c3VVP+ORBNtzS7XyV3NzsX lOo85Z3VvMO0Q+sup0fvsEQRY9i0QYXdQTBIkxu/t/bgRQIh4JZCF8/ZK2VWNAcm BA2o/X3KLu/qSHw3TT8An4Pf73WELnlXXPxXbhqW//yMmqaZviXZf5YsBvcRKgKA gOtjGDxQSYflispfGStZloEAoPtR28p3CwvJlk/vcEnHXG0g/Zm0tOLKLnf9LdwL tmsTDIwZKxeWmLnwi/agJ7u2441Rj72ux5uxiZ0CAwEAAaOCAYAwggF8MA4GA1Ud DwEB/wQEAwIBhjAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwEgYDVR0T AQH/BAgwBgEB/wIBADAdBgNVHQ4EFgQUinR/r4XN7pXNPZzQ4kYU83E1HScwHwYD VR0jBBgwFoAU5K8rJnEaK0gnhS9SZizv8IkTcT4waAYIKwYBBQUHAQEEXDBaMCYG CCsGAQUFBzABhhpodHRwOi8vb2NzcC5wa2kuZ29vZy9ndHNyMTAwBggrBgEFBQcw AoYkaHR0cDovL3BraS5nb29nL3JlcG8vY2VydHMvZ3RzcjEuZGVyMDQGA1UdHwQt MCswKaAnoCWGI2h0dHA6Ly9jcmwucGtpLmdvb2cvZ3RzcjEvZ3RzcjEuY3JsMFcG A1UdIARQME4wOAYKKwYBBAHWeQIFAzAqMCgGCCsGAQUFBwIBFhxodHRwczovL3Br aS5nb29nL3JlcG9zaXRvcnkvMAgGBmeBDAECATAIBgZngQwBAgIwDQYJKoZIhvcN AQELBQADggIBAIl9rCBcDDy+mqhXlRu0rvqrpXJxtDaV/d9AEQNMwkYUuxQkq/BQ cSLbrcRuf8/xam/IgxvYzolfh2yHuKkMo5uhYpSTld9brmYZCwKWnvy15xBpPnrL RklfRuFBsdeYTWU0AIAaP0+fbH9JAIFTQaSSIYKCGvGjRFsqUBITTcFTNvNCCK9U +o53UxtkOCcXCb1YyRt8OS1b887U7ZfbFAO/CVMkH8IMBHmYJvJh8VNS/UKMG2Yr PxWhu//2m+OBmgEGcYk1KCTd4b3rGS3hSMs9WYNRtHTGnXzGsYZbr8w0xNPM1IER lQCh9BIiAfq0g3GvjLeMcySsN1PCAJA/Ef5c7TaUEDu9Ka7ixzpiO2xj2YC/WXGs Yye5TBeg2vZzFb8q3o/zpWwygTMD0IZRcZk0upONXbVRWPeyk+gB9lm+cZv9TSjO z23HFtz30dZGm6fKa+l3D/2gthsjgx0QGtkJAITgRNOidSOzNIb2ILCkXhAd4FJG AJ2xDx8hcFH1mt0G/FX0Kw4zd8NLQsLxdxP8c4CU6x+7Nz/OAipmsHMdMqUybDKw juDEI/9bfU1lcKwrmz3O2+BtjjKAvpafkmO8l7tdufThcV4q5O8DIrGKZTqPwJNl 1IXNDw9bg1kWRxYtnCQ6yICmJhSFm/Y3m6xv+cXDBlHz4n/FsRC6UfTd -----END CERTIFICATE-----` const startComHex = "308206343082041ca003020102020118300d06092a864886f70d0101050500307d310b30" + "0906035504061302494c31163014060355040a130d5374617274436f6d204c74642e312b" + "3029060355040b1322536563757265204469676974616c20436572746966696361746520" + "5369676e696e6731293027060355040313205374617274436f6d20436572746966696361" + "74696f6e20417574686f72697479301e170d3037313032343230353431375a170d313731" + "3032343230353431375a30818c310b300906035504061302494c31163014060355040a13" + "0d5374617274436f6d204c74642e312b3029060355040b13225365637572652044696769" + "74616c204365727469666963617465205369676e696e67313830360603550403132f5374" + "617274436f6d20436c6173732031205072696d61727920496e7465726d65646961746520" + "53657276657220434130820122300d06092a864886f70d01010105000382010f00308201" + "0a0282010100b689c6acef09527807ac9263d0f44418188480561f91aee187fa3250b4d3" + "4706f0e6075f700e10f71dc0ce103634855a0f92ac83c6ac58523fba38e8fce7a724e240" + "a60876c0926e9e2a6d4d3f6e61200adb59ded27d63b33e46fefa215118d7cd30a6ed076e" + "3b7087b4f9faebee823c056f92f7a4dc0a301e9373fe07cad75f809d225852ae06da8b87" + "2369b0e42ad8ea83d2bdf371db705a280faf5a387045123f304dcd3baf17e50fcba0a95d" + "48aab16150cb34cd3c5cc30be810c08c9bf0030362feb26c3e720eee1c432ac9480e5739" + "c43121c810c12c87fe5495521f523c31129b7fe7c0a0a559d5e28f3ef0d5a8e1d77031a9" + "c4b3cfaf6d532f06f4a70203010001a38201ad308201a9300f0603551d130101ff040530" + "030101ff300e0603551d0f0101ff040403020106301d0603551d0e04160414eb4234d098" + "b0ab9ff41b6b08f7cc642eef0e2c45301f0603551d230418301680144e0bef1aa4405ba5" + "17698730ca346843d041aef2306606082b06010505070101045a3058302706082b060105" + "05073001861b687474703a2f2f6f6373702e737461727473736c2e636f6d2f6361302d06" + "082b060105050730028621687474703a2f2f7777772e737461727473736c2e636f6d2f73" + "667363612e637274305b0603551d1f045430523027a025a0238621687474703a2f2f7777" + "772e737461727473736c2e636f6d2f73667363612e63726c3027a025a023862168747470" + "3a2f2f63726c2e737461727473736c2e636f6d2f73667363612e63726c3081800603551d" + "20047930773075060b2b0601040181b5370102013066302e06082b060105050702011622" + "687474703a2f2f7777772e737461727473736c2e636f6d2f706f6c6963792e7064663034" + "06082b060105050702011628687474703a2f2f7777772e737461727473736c2e636f6d2f" + "696e7465726d6564696174652e706466300d06092a864886f70d01010505000382020100" + "2109493ea5886ee00b8b48da314d8ff75657a2e1d36257e9b556f38545753be5501f048b" + "e6a05a3ee700ae85d0fbff200364cbad02e1c69172f8a34dd6dee8cc3fa18aa2e37c37a7" + "c64f8f35d6f4d66e067bdd21d9cf56ffcb302249fe8904f385e5aaf1e71fe875904dddf9" + "46f74234f745580c110d84b0c6da5d3ef9019ee7e1da5595be741c7bfc4d144fac7e5547" + "7d7bf4a50d491e95e8f712c1ccff76a62547d0f37535be97b75816ebaa5c786fec5330af" + "ea044dcca902e3f0b60412f630b1113d904e5664d7dc3c435f7339ef4baf87ebf6fe6888" + "4472ead207c669b0c1a18bef1749d761b145485f3b2021e95bb2ccf4d7e931f50b15613b" + "7a94e3ebd9bc7f94ae6ae3626296a8647cb887f399327e92a252bebbf865cfc9f230fc8b" + "c1c2a696d75f89e15c3480f58f47072fb491bfb1a27e5f4b5ad05b9f248605515a690365" + "434971c5e06f94346bf61bd8a9b04c7e53eb8f48dfca33b548fa364a1a53a6330cd089cd" + "4915cd89313c90c072d7654b52358a461144b93d8e2865a63e799e5c084429adb035112e" + "214eb8d2e7103e5d8483b3c3c2e4d2c6fd094b7409ddf1b3d3193e800da20b19f038e7c5" + "c2afe223db61e29d5c6e2089492e236ab262c145b49faf8ba7f1223bf87de290d07a19fb" + "4a4ce3d27d5f4a8303ed27d6239e6b8db459a2d9ef6c8229dd75193c3f4c108defbb7527" + "d2ae83a7a8ce5ba7" const ocspResponseWithoutCertHex = "308201d40a0100a08201cd308201c906092b0601050507300101048201ba3082" + "01b630819fa2160414884451ff502a695e2d88f421bad90cf2cecbea7c180f3230313330" + "3631383037323434335a30743072304a300906052b0e03021a0500041448b60d38238df8" + "456e4ee5843ea394111802979f0414884451ff502a695e2d88f421bad90cf2cecbea7c02" + "1100f78b13b946fc9635d8ab49de9d2148218000180f3230313330363138303732343433" + "5aa011180f32303133303632323037323434335a300d06092a864886f70d010105050003" + "82010100103e18b3d297a5e7a6c07a4fc52ac46a15c0eba96f3be17f0ffe84de5b8c8e05" + "5a8f577586a849dc4abd6440eb6fedde4622451e2823c1cbf3558b4e8184959c9fe96eff" + "8bc5f95866c58c6d087519faabfdae37e11d9874f1bc0db292208f645dd848185e4dd38b" + "6a8547dfa7b74d514a8470015719064d35476b95bebb03d4d2845c5ca15202d2784878f2" + "0f904c24f09736f044609e9c271381713400e563023d212db422236440c6f377bbf24b2b" + "9e7dec8698e36a8df68b7592ad3489fb2937afb90eb85d2aa96b81c94c25057dbd4759d9" + "20a1a65c7f0b6427a224b3c98edd96b9b61f706099951188b0289555ad30a216fb774651" + "5a35fca2e054dfa8" // PKIX nonce extension var ocspExtensionOID = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 7, 48, 1, 2} var ocspExtensionValueHex = "0403000000" const ocspResponseWithCriticalExtensionHex = "308204fe0a0100a08204f7308204f306092b0601050507300101048204e4308204e03081" + "dba003020100a11b3019311730150603550403130e4f43535020526573706f6e64657218" + "0f32303136303130343137303130305a3081a53081a23049300906052b0e03021a050004" + "14c0fe0278fc99188891b3f212e9c7e1b21ab7bfc004140dfc1df0a9e0f01ce7f2b21317" + "7e6f8d157cd4f60210017f77deb3bcbb235d44ccc7dba62e72a116180f32303130303730" + "373135303130355aa0030a0101180f32303130303730373135303130355aa011180f3230" + "3130303730373138333531375aa1193017301506092b06010505073001020101ff040504" + "03000000300d06092a864886f70d01010b0500038201010031c730ca60a7a0d92d8e4010" + "911b469de95b4d27e89de6537552436237967694f76f701cf6b45c932bd308bca4a8d092" + "5c604ba94796903091d9e6c000178e72c1f0a24a277dd262835af5d17d3f9d7869606c9f" + "e7c8e708a41645699895beee38bfa63bb46296683761c5d1d65439b8ab868dc3017c9eeb" + "b70b82dbf3a31c55b457d48bb9e82b335ed49f445042eaf606b06a3e0639824924c89c63" + "eccddfe85e6694314138b2536f5e15e07085d0f6e26d4b2f8244bab0d70de07283ac6384" + "a0501fc3dea7cf0adfd4c7f34871080900e252ddc403e3f0265f2a704af905d3727504ed" + "28f3214a219d898a022463c78439799ca81c8cbafdbcec34ea937cd6a08202ea308202e6" + "308202e2308201caa003020102020101300d06092a864886f70d01010b05003019311730" + "150603550403130e4f43535020526573706f6e646572301e170d31353031333031353530" + "33335a170d3136303133303135353033335a3019311730150603550403130e4f43535020" + "526573706f6e64657230820122300d06092a864886f70d01010105000382010f00308201" + "0a0282010100e8155f2d3e6f2e8d14c62a788bd462f9f844e7a6977c83ef1099f0f6616e" + "c5265b56f356e62c5400f0b06a2e7945a82752c636df32a895152d6074df1701dc6ccfbc" + "bec75a70bd2b55ae2be7e6cad3b5fd4cd5b7790ab401a436d3f5f346074ffde8a99d5b72" + "3350f0a112076614b12ef79c78991b119453445acf2416ab0046b540db14c9fc0f27b898" + "9ad0f63aa4b8aefc91aa8a72160c36307c60fec78a93d3fddf4259902aa77e7332971c7d" + "285b6a04f648993c6922a3e9da9adf5f81508c3228791843e5d49f24db2f1290bafd97e6" + "55b1049a199f652cd603c4fafa330c390b0da78fbbc67e8fa021cbd74eb96222b12ace31" + "a77dcf920334dc94581b0203010001a3353033300e0603551d0f0101ff04040302078030" + "130603551d25040c300a06082b06010505070309300c0603551d130101ff04023000300d" + "06092a864886f70d01010b05000382010100718012761b5063e18f0dc44644d8e6ab8612" + "31c15fd5357805425d82aec1de85bf6d3e30fce205e3e3b8b795bbe52e40a439286d2288" + "9064f4aeeb150359b9425f1da51b3a5c939018555d13ac42c565a0603786a919328f3267" + "09dce52c22ad958ecb7873b9771d1148b1c4be2efe80ba868919fc9f68b6090c2f33c156" + "d67156e42766a50b5d51e79637b7e58af74c2a951b1e642fa7741fec982cc937de37eff5" + "9e2005d5939bfc031589ca143e6e8ab83f40ee08cc20a6b4a95a318352c28d18528dcaf9" + "66705de17afa19d6e8ae91ddf33179d16ebb6ac2c69cae8373d408ebf8c55308be6c04d9" + "3a25439a94299a65a709756c7a3e568be049d5c38839" const ocspResponseWithExtensionHex = "308204fb0a0100a08204f4308204f006092b0601050507300101048204e1308204dd3081" + "d8a003020100a11b3019311730150603550403130e4f43535020526573706f6e64657218" + "0f32303136303130343136353930305a3081a230819f3049300906052b0e03021a050004" + "14c0fe0278fc99188891b3f212e9c7e1b21ab7bfc004140dfc1df0a9e0f01ce7f2b21317" + "7e6f8d157cd4f60210017f77deb3bcbb235d44ccc7dba62e72a116180f32303130303730" + "373135303130355aa0030a0101180f32303130303730373135303130355aa011180f3230" + "3130303730373138333531375aa1163014301206092b0601050507300102040504030000" + "00300d06092a864886f70d01010b05000382010100c09a33e0b2324c852421bb83f85ac9" + "9113f5426012bd2d2279a8166e9241d18a33c870894250622ffc7ed0c4601b16d624f90b" + "779265442cdb6868cf40ab304ab4b66e7315ed02cf663b1601d1d4751772b31bc299db23" + "9aebac78ed6797c06ed815a7a8d18d63cfbb609cafb47ec2e89e37db255216eb09307848" + "d01be0a3e943653c78212b96ff524b74c9ec456b17cdfb950cc97645c577b2e09ff41dde" + "b03afb3adaa381cc0f7c1d95663ef22a0f72f2c45613ae8e2b2d1efc96e8463c7d1d8a1d" + "7e3b35df8fe73a301fc3f804b942b2b3afa337ff105fc1462b7b1c1d75eb4566c8665e59" + "f80393b0adbf8004ff6c3327ed34f007cb4a3348a7d55e06e3a08202ea308202e6308202" + "e2308201caa003020102020101300d06092a864886f70d01010b05003019311730150603" + "550403130e4f43535020526573706f6e646572301e170d3135303133303135353033335a" + "170d3136303133303135353033335a3019311730150603550403130e4f43535020526573" + "706f6e64657230820122300d06092a864886f70d01010105000382010f003082010a0282" + "010100e8155f2d3e6f2e8d14c62a788bd462f9f844e7a6977c83ef1099f0f6616ec5265b" + "56f356e62c5400f0b06a2e7945a82752c636df32a895152d6074df1701dc6ccfbcbec75a" + "70bd2b55ae2be7e6cad3b5fd4cd5b7790ab401a436d3f5f346074ffde8a99d5b723350f0" + "a112076614b12ef79c78991b119453445acf2416ab0046b540db14c9fc0f27b8989ad0f6" + "3aa4b8aefc91aa8a72160c36307c60fec78a93d3fddf4259902aa77e7332971c7d285b6a" + "04f648993c6922a3e9da9adf5f81508c3228791843e5d49f24db2f1290bafd97e655b104" + "9a199f652cd603c4fafa330c390b0da78fbbc67e8fa021cbd74eb96222b12ace31a77dcf" + "920334dc94581b0203010001a3353033300e0603551d0f0101ff04040302078030130603" + "551d25040c300a06082b06010505070309300c0603551d130101ff04023000300d06092a" + "864886f70d01010b05000382010100718012761b5063e18f0dc44644d8e6ab861231c15f" + "d5357805425d82aec1de85bf6d3e30fce205e3e3b8b795bbe52e40a439286d22889064f4" + "aeeb150359b9425f1da51b3a5c939018555d13ac42c565a0603786a919328f326709dce5" + "2c22ad958ecb7873b9771d1148b1c4be2efe80ba868919fc9f68b6090c2f33c156d67156" + "e42766a50b5d51e79637b7e58af74c2a951b1e642fa7741fec982cc937de37eff59e2005" + "d5939bfc031589ca143e6e8ab83f40ee08cc20a6b4a95a318352c28d18528dcaf966705d" + "e17afa19d6e8ae91ddf33179d16ebb6ac2c69cae8373d408ebf8c55308be6c04d93a2543" + "9a94299a65a709756c7a3e568be049d5c38839" const ocspRequestHex = "3051304f304d304b3049300906052b0e03021a05000414c0fe0278fc99188891b3f212e9" + "c7e1b21ab7bfc004140dfc1df0a9e0f01ce7f2b213177e6f8d157cd4f60210017f77deb3" + "bcbb235d44ccc7dba62e72" const leafCertHex = "308203c830820331a0030201020210017f77deb3bcbb235d44ccc7dba62e72300d06092a" + "864886f70d01010505003081ba311f301d060355040a1316566572695369676e20547275" + "7374204e6574776f726b31173015060355040b130e566572695369676e2c20496e632e31" + "333031060355040b132a566572695369676e20496e7465726e6174696f6e616c20536572" + "766572204341202d20436c617373203331493047060355040b13407777772e7665726973" + "69676e2e636f6d2f43505320496e636f72702e6279205265662e204c494142494c495459" + "204c54442e286329393720566572695369676e301e170d3132303632313030303030305a" + "170d3133313233313233353935395a3068310b3009060355040613025553311330110603" + "550408130a43616c69666f726e6961311230100603550407130950616c6f20416c746f31" + "173015060355040a130e46616365626f6f6b2c20496e632e311730150603550403140e2a" + "2e66616365626f6f6b2e636f6d30819f300d06092a864886f70d010101050003818d0030" + "818902818100ae94b171e2deccc1693e051063240102e0689ae83c39b6b3e74b97d48d7b" + "23689100b0b496ee62f0e6d356bcf4aa0f50643402f5d1766aa972835a7564723f39bbef" + "5290ded9bcdbf9d3d55dfad23aa03dc604c54d29cf1d4b3bdbd1a809cfae47b44c7eae17" + "c5109bee24a9cf4a8d911bb0fd0415ae4c3f430aa12a557e2ae10203010001a382011e30" + "82011a30090603551d130402300030440603551d20043d303b3039060b6086480186f845" + "01071703302a302806082b06010505070201161c68747470733a2f2f7777772e76657269" + "7369676e2e636f6d2f727061303c0603551d1f043530333031a02fa02d862b687474703a" + "2f2f535652496e746c2d63726c2e766572697369676e2e636f6d2f535652496e746c2e63" + "726c301d0603551d250416301406082b0601050507030106082b06010505070302300b06" + "03551d0f0404030205a0303406082b0601050507010104283026302406082b0601050507" + "30018618687474703a2f2f6f6373702e766572697369676e2e636f6d30270603551d1104" + "20301e820e2a2e66616365626f6f6b2e636f6d820c66616365626f6f6b2e636f6d300d06" + "092a864886f70d0101050500038181005b6c2b75f8ed30aa51aad36aba595e555141951f" + "81a53b447910ac1f76ff78fc2781616b58f3122afc1c87010425e9ed43df1a7ba6498060" + "67e2688af03db58c7df4ee03309a6afc247ccb134dc33e54c6bc1d5133a532a73273b1d7" + "9cadc08e7e1a83116d34523340b0305427a21742827c98916698ee7eaf8c3bdd71700817" const issuerCertHex = "30820383308202eca003020102021046fcebbab4d02f0f926098233f93078f300d06092a" + "864886f70d0101050500305f310b300906035504061302555331173015060355040a130e" + "566572695369676e2c20496e632e31373035060355040b132e436c617373203320507562" + "6c6963205072696d6172792043657274696669636174696f6e20417574686f7269747930" + "1e170d3937303431373030303030305a170d3136313032343233353935395a3081ba311f" + "301d060355040a1316566572695369676e205472757374204e6574776f726b3117301506" + "0355040b130e566572695369676e2c20496e632e31333031060355040b132a5665726953" + "69676e20496e7465726e6174696f6e616c20536572766572204341202d20436c61737320" + "3331493047060355040b13407777772e766572697369676e2e636f6d2f43505320496e63" + "6f72702e6279205265662e204c494142494c495459204c54442e28632939372056657269" + "5369676e30819f300d06092a864886f70d010101050003818d0030818902818100d88280" + "e8d619027d1f85183925a2652be1bfd405d3bce6363baaf04c6c5bb6e7aa3c734555b2f1" + "bdea9742ed9a340a15d4a95cf54025ddd907c132b2756cc4cabba3fe56277143aa63f530" + "3e9328e5faf1093bf3b74d4e39f75c495ab8c11dd3b28afe70309542cbfe2b518b5a3c3a" + "f9224f90b202a7539c4f34e7ab04b27b6f0203010001a381e33081e0300f0603551d1304" + "0830060101ff02010030440603551d20043d303b3039060b6086480186f8450107010130" + "2a302806082b06010505070201161c68747470733a2f2f7777772e766572697369676e2e" + "636f6d2f43505330340603551d25042d302b06082b0601050507030106082b0601050507" + "030206096086480186f8420401060a6086480186f845010801300b0603551d0f04040302" + "0106301106096086480186f842010104040302010630310603551d1f042a30283026a024" + "a0228620687474703a2f2f63726c2e766572697369676e2e636f6d2f706361332e63726c" + "300d06092a864886f70d010105050003818100408e4997968a73dd8e4def3e61b7caa062" + "adf40e0abb753de26ed82cc7bff4b98c369bcaa2d09c724639f6a682036511c4bcbf2da6" + "f5d93b0ab598fab378b91ef22b4c62d5fdb27a1ddf33fd73f9a5d82d8c2aead1fcb028b6" + "e94948134b838a1b487b24f738de6f4154b8ab576b06dfc7a2d4a9f6f136628088f28b75" + "d68071" // Key and certificate for the OCSP responder were not taken from the Thawte // responder, since CreateResponse requires that we have the private key. // Instead, they were generated randomly. const responderPrivateKeyHex = "308204a40201000282010100e8155f2d3e6f2e8d14c62a788bd462f9f844e7a6977c83ef" + "1099f0f6616ec5265b56f356e62c5400f0b06a2e7945a82752c636df32a895152d6074df" + "1701dc6ccfbcbec75a70bd2b55ae2be7e6cad3b5fd4cd5b7790ab401a436d3f5f346074f" + "fde8a99d5b723350f0a112076614b12ef79c78991b119453445acf2416ab0046b540db14" + "c9fc0f27b8989ad0f63aa4b8aefc91aa8a72160c36307c60fec78a93d3fddf4259902aa7" + "7e7332971c7d285b6a04f648993c6922a3e9da9adf5f81508c3228791843e5d49f24db2f" + "1290bafd97e655b1049a199f652cd603c4fafa330c390b0da78fbbc67e8fa021cbd74eb9" + "6222b12ace31a77dcf920334dc94581b02030100010282010100bcf0b93d7238bda329a8" + "72e7149f61bcb37c154330ccb3f42a85c9002c2e2bdea039d77d8581cd19bed94078794e" + "56293d601547fc4bf6a2f9002fe5772b92b21b254403b403585e3130cc99ccf08f0ef81a" + "575b38f597ba4660448b54f44bfbb97072b5a2bf043bfeca828cf7741d13698e3f38162b" + "679faa646b82abd9a72c5c7d722c5fc577a76d2c2daac588accad18516d1bbad10b0dfa2" + "05cfe246b59e28608a43942e1b71b0c80498075121de5b900d727c31c42c78cf1db5c0aa" + "5b491e10ea4ed5c0962aaf2ae025dd81fa4ce490d9d6b4a4465411d8e542fc88617e5695" + "1aa4fc8ea166f2b4d0eb89ef17f2b206bd5f1014bf8fe0e71fe62f2cccf102818100f2dc" + "ddf878d553286daad68bac4070a82ffec3dc4666a2750f47879eec913f91836f1d976b60" + "daf9356e078446dafab5bd2e489e5d64f8572ba24a4ba4f3729b5e106c4dd831cc2497a7" + "e6c7507df05cb64aeb1bbc81c1e340d58b5964cf39cff84ea30c29ec5d3f005ee1362698" + "07395037955955655292c3e85f6187fa1f9502818100f4a33c102630840705f8c778a47b" + "87e8da31e68809af981ac5e5999cf1551685d761cdf0d6520361b99aebd5777a940fa64d" + "327c09fa63746fbb3247ec73a86edf115f1fe5c83598db803881ade71c33c6e956118345" + "497b98b5e07bb5be75971465ec78f2f9467e1b74956ca9d4c7c3e314e742a72d8b33889c" + "6c093a466cef0281801d3df0d02124766dd0be98349b19eb36a508c4e679e793ba0a8bef" + "4d786888c1e9947078b1ea28938716677b4ad8c5052af12eb73ac194915264a913709a0b" + "7b9f98d4a18edd781a13d49899f91c20dbd8eb2e61d991ba19b5cdc08893f5cb9d39e5a6" + "0629ea16d426244673b1b3ee72bd30e41fac8395acac40077403de5efd028180050731dd" + "d71b1a2b96c8d538ba90bb6b62c8b1c74c03aae9a9f59d21a7a82b0d572ef06fa9c807bf" + "c373d6b30d809c7871df96510c577421d9860c7383fda0919ece19996b3ca13562159193" + "c0c246471e287f975e8e57034e5136aaf44254e2650def3d51292474c515b1588969112e" + "0a85cc77073e9d64d2c2fc497844284b02818100d71d63eabf416cf677401ebf965f8314" + "120b568a57dd3bd9116c629c40dc0c6948bab3a13cc544c31c7da40e76132ef5dd3f7534" + "45a635930c74326ae3df0edd1bfb1523e3aa259873ac7cf1ac31151ec8f37b528c275622" + "48f99b8bed59fd4da2576aa6ee20d93a684900bf907e80c66d6e2261ae15e55284b4ed9d" + "6bdaa059" const responderCertHex = "308202e2308201caa003020102020101300d06092a864886f70d01010b05003019311730" + "150603550403130e4f43535020526573706f6e646572301e170d31353031333031353530" + "33335a170d3136303133303135353033335a3019311730150603550403130e4f43535020" + "526573706f6e64657230820122300d06092a864886f70d01010105000382010f00308201" + "0a0282010100e8155f2d3e6f2e8d14c62a788bd462f9f844e7a6977c83ef1099f0f6616e" + "c5265b56f356e62c5400f0b06a2e7945a82752c636df32a895152d6074df1701dc6ccfbc" + "bec75a70bd2b55ae2be7e6cad3b5fd4cd5b7790ab401a436d3f5f346074ffde8a99d5b72" + "3350f0a112076614b12ef79c78991b119453445acf2416ab0046b540db14c9fc0f27b898" + "9ad0f63aa4b8aefc91aa8a72160c36307c60fec78a93d3fddf4259902aa77e7332971c7d" + "285b6a04f648993c6922a3e9da9adf5f81508c3228791843e5d49f24db2f1290bafd97e6" + "55b1049a199f652cd603c4fafa330c390b0da78fbbc67e8fa021cbd74eb96222b12ace31" + "a77dcf920334dc94581b0203010001a3353033300e0603551d0f0101ff04040302078030" + "130603551d25040c300a06082b06010505070309300c0603551d130101ff04023000300d" + "06092a864886f70d01010b05000382010100718012761b5063e18f0dc44644d8e6ab8612" + "31c15fd5357805425d82aec1de85bf6d3e30fce205e3e3b8b795bbe52e40a439286d2288" + "9064f4aeeb150359b9425f1da51b3a5c939018555d13ac42c565a0603786a919328f3267" + "09dce52c22ad958ecb7873b9771d1148b1c4be2efe80ba868919fc9f68b6090c2f33c156" + "d67156e42766a50b5d51e79637b7e58af74c2a951b1e642fa7741fec982cc937de37eff5" + "9e2005d5939bfc031589ca143e6e8ab83f40ee08cc20a6b4a95a318352c28d18528dcaf9" + "66705de17afa19d6e8ae91ddf33179d16ebb6ac2c69cae8373d408ebf8c55308be6c04d9" + "3a25439a94299a65a709756c7a3e568be049d5c38839" const errorResponseHex = "30030a0101"
crypto/ocsp/ocsp_test.go/0
{ "file_path": "crypto/ocsp/ocsp_test.go", "repo_id": "crypto", "token_count": 18098 }
6
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "crypto" "crypto/rand" "io" "time" ) // Config collects a number of parameters along with sensible defaults. // A nil *Config is valid and results in all default values. type Config struct { // Rand provides the source of entropy. // If nil, the crypto/rand Reader is used. Rand io.Reader // DefaultHash is the default hash function to be used. // If zero, SHA-256 is used. DefaultHash crypto.Hash // DefaultCipher is the cipher to be used. // If zero, AES-128 is used. DefaultCipher CipherFunction // Time returns the current time as the number of seconds since the // epoch. If Time is nil, time.Now is used. Time func() time.Time // DefaultCompressionAlgo is the compression algorithm to be // applied to the plaintext before encryption. If zero, no // compression is done. DefaultCompressionAlgo CompressionAlgo // CompressionConfig configures the compression settings. CompressionConfig *CompressionConfig // S2KCount is only used for symmetric encryption. It // determines the strength of the passphrase stretching when // the said passphrase is hashed to produce a key. S2KCount // should be between 1024 and 65011712, inclusive. If Config // is nil or S2KCount is 0, the value 65536 used. Not all // values in the above range can be represented. S2KCount will // be rounded up to the next representable value if it cannot // be encoded exactly. When set, it is strongly encrouraged to // use a value that is at least 65536. See RFC 4880 Section // 3.7.1.3. S2KCount int // RSABits is the number of bits in new RSA keys made with NewEntity. // If zero, then 2048 bit keys are created. RSABits int } func (c *Config) Random() io.Reader { if c == nil || c.Rand == nil { return rand.Reader } return c.Rand } func (c *Config) Hash() crypto.Hash { if c == nil || uint(c.DefaultHash) == 0 { return crypto.SHA256 } return c.DefaultHash } func (c *Config) Cipher() CipherFunction { if c == nil || uint8(c.DefaultCipher) == 0 { return CipherAES128 } return c.DefaultCipher } func (c *Config) Now() time.Time { if c == nil || c.Time == nil { return time.Now() } return c.Time() } func (c *Config) Compression() CompressionAlgo { if c == nil { return CompressionNone } return c.DefaultCompressionAlgo } func (c *Config) PasswordHashIterations() int { if c == nil || c.S2KCount == 0 { return 0 } return c.S2KCount }
crypto/openpgp/packet/config.go/0
{ "file_path": "crypto/openpgp/packet/config.go", "repo_id": "crypto", "token_count": 814 }
7
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package packet import ( "bytes" "encoding/hex" "testing" "time" ) var pubKeyV3Test = struct { hexFingerprint string creationTime time.Time pubKeyAlgo PublicKeyAlgorithm keyId uint64 keyIdString string keyIdShort string }{ "103BECF5BD1E837C89D19E98487767F7", time.Unix(779753634, 0), PubKeyAlgoRSA, 0xDE0F188A5DA5E3C9, "DE0F188A5DA5E3C9", "5DA5E3C9"} func TestPublicKeyV3Read(t *testing.T) { i, test := 0, pubKeyV3Test packet, err := Read(v3KeyReader(t)) if err != nil { t.Fatalf("#%d: Read error: %s", i, err) } pk, ok := packet.(*PublicKeyV3) if !ok { t.Fatalf("#%d: failed to parse, got: %#v", i, packet) } if pk.PubKeyAlgo != test.pubKeyAlgo { t.Errorf("#%d: bad public key algorithm got:%x want:%x", i, pk.PubKeyAlgo, test.pubKeyAlgo) } if !pk.CreationTime.Equal(test.creationTime) { t.Errorf("#%d: bad creation time got:%v want:%v", i, pk.CreationTime, test.creationTime) } expectedFingerprint, _ := hex.DecodeString(test.hexFingerprint) if !bytes.Equal(expectedFingerprint, pk.Fingerprint[:]) { t.Errorf("#%d: bad fingerprint got:%x want:%x", i, pk.Fingerprint[:], expectedFingerprint) } if pk.KeyId != test.keyId { t.Errorf("#%d: bad keyid got:%x want:%x", i, pk.KeyId, test.keyId) } if g, e := pk.KeyIdString(), test.keyIdString; g != e { t.Errorf("#%d: bad KeyIdString got:%q want:%q", i, g, e) } if g, e := pk.KeyIdShortString(), test.keyIdShort; g != e { t.Errorf("#%d: bad KeyIdShortString got:%q want:%q", i, g, e) } } func TestPublicKeyV3Serialize(t *testing.T) { //for i, test := range pubKeyV3Tests { i := 0 packet, err := Read(v3KeyReader(t)) if err != nil { t.Fatalf("#%d: Read error: %s", i, err) } pk, ok := packet.(*PublicKeyV3) if !ok { t.Fatalf("#%d: failed to parse, got: %#v", i, packet) } var serializeBuf bytes.Buffer if err = pk.Serialize(&serializeBuf); err != nil { t.Fatalf("#%d: failed to serialize: %s", i, err) } if packet, err = Read(bytes.NewBuffer(serializeBuf.Bytes())); err != nil { t.Fatalf("#%d: Read error (from serialized data): %s", i, err) } if pk, ok = packet.(*PublicKeyV3); !ok { t.Fatalf("#%d: failed to parse serialized data, got: %#v", i, packet) } }
crypto/openpgp/packet/public_key_v3_test.go/0
{ "file_path": "crypto/openpgp/packet/public_key_v3_test.go", "repo_id": "crypto", "token_count": 1058 }
8
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package s2k implements the various OpenPGP string-to-key transforms as // specified in RFC 4800 section 3.7.1. // // Deprecated: this package is unmaintained except for security fixes. New // applications should consider a more focused, modern alternative to OpenPGP // for their specific task. If you are required to interoperate with OpenPGP // systems and need a maintained package, consider a community fork. // See https://golang.org/issue/44226. package s2k import ( "crypto" "hash" "io" "strconv" "golang.org/x/crypto/openpgp/errors" ) // Config collects configuration parameters for s2k key-stretching // transformatioms. A nil *Config is valid and results in all default // values. Currently, Config is used only by the Serialize function in // this package. type Config struct { // Hash is the default hash function to be used. If // nil, SHA1 is used. Hash crypto.Hash // S2KCount is only used for symmetric encryption. It // determines the strength of the passphrase stretching when // the said passphrase is hashed to produce a key. S2KCount // should be between 1024 and 65011712, inclusive. If Config // is nil or S2KCount is 0, the value 65536 used. Not all // values in the above range can be represented. S2KCount will // be rounded up to the next representable value if it cannot // be encoded exactly. When set, it is strongly encrouraged to // use a value that is at least 65536. See RFC 4880 Section // 3.7.1.3. S2KCount int } func (c *Config) hash() crypto.Hash { if c == nil || uint(c.Hash) == 0 { // SHA1 is the historical default in this package. return crypto.SHA1 } return c.Hash } func (c *Config) encodedCount() uint8 { if c == nil || c.S2KCount == 0 { return 96 // The common case. Correspoding to 65536 } i := c.S2KCount switch { // Behave like GPG. Should we make 65536 the lowest value used? case i < 1024: i = 1024 case i > 65011712: i = 65011712 } return encodeCount(i) } // encodeCount converts an iterative "count" in the range 1024 to // 65011712, inclusive, to an encoded count. The return value is the // octet that is actually stored in the GPG file. encodeCount panics // if i is not in the above range (encodedCount above takes care to // pass i in the correct range). See RFC 4880 Section 3.7.7.1. func encodeCount(i int) uint8 { if i < 1024 || i > 65011712 { panic("count arg i outside the required range") } for encoded := 0; encoded < 256; encoded++ { count := decodeCount(uint8(encoded)) if count >= i { return uint8(encoded) } } return 255 } // decodeCount returns the s2k mode 3 iterative "count" corresponding to // the encoded octet c. func decodeCount(c uint8) int { return (16 + int(c&15)) << (uint32(c>>4) + 6) } // Simple writes to out the result of computing the Simple S2K function (RFC // 4880, section 3.7.1.1) using the given hash and input passphrase. func Simple(out []byte, h hash.Hash, in []byte) { Salted(out, h, in, nil) } var zero [1]byte // Salted writes to out the result of computing the Salted S2K function (RFC // 4880, section 3.7.1.2) using the given hash, input passphrase and salt. func Salted(out []byte, h hash.Hash, in []byte, salt []byte) { done := 0 var digest []byte for i := 0; done < len(out); i++ { h.Reset() for j := 0; j < i; j++ { h.Write(zero[:]) } h.Write(salt) h.Write(in) digest = h.Sum(digest[:0]) n := copy(out[done:], digest) done += n } } // Iterated writes to out the result of computing the Iterated and Salted S2K // function (RFC 4880, section 3.7.1.3) using the given hash, input passphrase, // salt and iteration count. func Iterated(out []byte, h hash.Hash, in []byte, salt []byte, count int) { combined := make([]byte, len(in)+len(salt)) copy(combined, salt) copy(combined[len(salt):], in) if count < len(combined) { count = len(combined) } done := 0 var digest []byte for i := 0; done < len(out); i++ { h.Reset() for j := 0; j < i; j++ { h.Write(zero[:]) } written := 0 for written < count { if written+len(combined) > count { todo := count - written h.Write(combined[:todo]) written = count } else { h.Write(combined) written += len(combined) } } digest = h.Sum(digest[:0]) n := copy(out[done:], digest) done += n } } // Parse reads a binary specification for a string-to-key transformation from r // and returns a function which performs that transform. func Parse(r io.Reader) (f func(out, in []byte), err error) { var buf [9]byte _, err = io.ReadFull(r, buf[:2]) if err != nil { return } hash, ok := HashIdToHash(buf[1]) if !ok { return nil, errors.UnsupportedError("hash for S2K function: " + strconv.Itoa(int(buf[1]))) } if !hash.Available() { return nil, errors.UnsupportedError("hash not available: " + strconv.Itoa(int(hash))) } h := hash.New() switch buf[0] { case 0: f := func(out, in []byte) { Simple(out, h, in) } return f, nil case 1: _, err = io.ReadFull(r, buf[:8]) if err != nil { return } f := func(out, in []byte) { Salted(out, h, in, buf[:8]) } return f, nil case 3: _, err = io.ReadFull(r, buf[:9]) if err != nil { return } count := decodeCount(buf[8]) f := func(out, in []byte) { Iterated(out, h, in, buf[:8], count) } return f, nil } return nil, errors.UnsupportedError("S2K function") } // Serialize salts and stretches the given passphrase and writes the // resulting key into key. It also serializes an S2K descriptor to // w. The key stretching can be configured with c, which may be // nil. In that case, sensible defaults will be used. func Serialize(w io.Writer, key []byte, rand io.Reader, passphrase []byte, c *Config) error { var buf [11]byte buf[0] = 3 /* iterated and salted */ buf[1], _ = HashToHashId(c.hash()) salt := buf[2:10] if _, err := io.ReadFull(rand, salt); err != nil { return err } encodedCount := c.encodedCount() count := decodeCount(encodedCount) buf[10] = encodedCount if _, err := w.Write(buf[:]); err != nil { return err } Iterated(key, c.hash().New(), passphrase, salt, count) return nil } // hashToHashIdMapping contains pairs relating OpenPGP's hash identifier with // Go's crypto.Hash type. See RFC 4880, section 9.4. var hashToHashIdMapping = []struct { id byte hash crypto.Hash name string }{ {1, crypto.MD5, "MD5"}, {2, crypto.SHA1, "SHA1"}, {3, crypto.RIPEMD160, "RIPEMD160"}, {8, crypto.SHA256, "SHA256"}, {9, crypto.SHA384, "SHA384"}, {10, crypto.SHA512, "SHA512"}, {11, crypto.SHA224, "SHA224"}, } // HashIdToHash returns a crypto.Hash which corresponds to the given OpenPGP // hash id. func HashIdToHash(id byte) (h crypto.Hash, ok bool) { for _, m := range hashToHashIdMapping { if m.id == id { return m.hash, true } } return 0, false } // HashIdToString returns the name of the hash function corresponding to the // given OpenPGP hash id. func HashIdToString(id byte) (name string, ok bool) { for _, m := range hashToHashIdMapping { if m.id == id { return m.name, true } } return "", false } // HashToHashId returns an OpenPGP hash id which corresponds the given Hash. func HashToHashId(h crypto.Hash) (id byte, ok bool) { for _, m := range hashToHashIdMapping { if m.hash == h { return m.id, true } } return 0, false }
crypto/openpgp/s2k/s2k.go/0
{ "file_path": "crypto/openpgp/s2k/s2k.go", "repo_id": "crypto", "token_count": 2716 }
9
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package rc2 implements the RC2 cipher /* https://www.ietf.org/rfc/rfc2268.txt http://people.csail.mit.edu/rivest/pubs/KRRR98.pdf This code is licensed under the MIT license. */ package rc2 import ( "crypto/cipher" "encoding/binary" "math/bits" ) // The rc2 block size in bytes const BlockSize = 8 type rc2Cipher struct { k [64]uint16 } // New returns a new rc2 cipher with the given key and effective key length t1 func New(key []byte, t1 int) (cipher.Block, error) { // TODO(dgryski): error checking for key length return &rc2Cipher{ k: expandKey(key, t1), }, nil } func (*rc2Cipher) BlockSize() int { return BlockSize } var piTable = [256]byte{ 0xd9, 0x78, 0xf9, 0xc4, 0x19, 0xdd, 0xb5, 0xed, 0x28, 0xe9, 0xfd, 0x79, 0x4a, 0xa0, 0xd8, 0x9d, 0xc6, 0x7e, 0x37, 0x83, 0x2b, 0x76, 0x53, 0x8e, 0x62, 0x4c, 0x64, 0x88, 0x44, 0x8b, 0xfb, 0xa2, 0x17, 0x9a, 0x59, 0xf5, 0x87, 0xb3, 0x4f, 0x13, 0x61, 0x45, 0x6d, 0x8d, 0x09, 0x81, 0x7d, 0x32, 0xbd, 0x8f, 0x40, 0xeb, 0x86, 0xb7, 0x7b, 0x0b, 0xf0, 0x95, 0x21, 0x22, 0x5c, 0x6b, 0x4e, 0x82, 0x54, 0xd6, 0x65, 0x93, 0xce, 0x60, 0xb2, 0x1c, 0x73, 0x56, 0xc0, 0x14, 0xa7, 0x8c, 0xf1, 0xdc, 0x12, 0x75, 0xca, 0x1f, 0x3b, 0xbe, 0xe4, 0xd1, 0x42, 0x3d, 0xd4, 0x30, 0xa3, 0x3c, 0xb6, 0x26, 0x6f, 0xbf, 0x0e, 0xda, 0x46, 0x69, 0x07, 0x57, 0x27, 0xf2, 0x1d, 0x9b, 0xbc, 0x94, 0x43, 0x03, 0xf8, 0x11, 0xc7, 0xf6, 0x90, 0xef, 0x3e, 0xe7, 0x06, 0xc3, 0xd5, 0x2f, 0xc8, 0x66, 0x1e, 0xd7, 0x08, 0xe8, 0xea, 0xde, 0x80, 0x52, 0xee, 0xf7, 0x84, 0xaa, 0x72, 0xac, 0x35, 0x4d, 0x6a, 0x2a, 0x96, 0x1a, 0xd2, 0x71, 0x5a, 0x15, 0x49, 0x74, 0x4b, 0x9f, 0xd0, 0x5e, 0x04, 0x18, 0xa4, 0xec, 0xc2, 0xe0, 0x41, 0x6e, 0x0f, 0x51, 0xcb, 0xcc, 0x24, 0x91, 0xaf, 0x50, 0xa1, 0xf4, 0x70, 0x39, 0x99, 0x7c, 0x3a, 0x85, 0x23, 0xb8, 0xb4, 0x7a, 0xfc, 0x02, 0x36, 0x5b, 0x25, 0x55, 0x97, 0x31, 0x2d, 0x5d, 0xfa, 0x98, 0xe3, 0x8a, 0x92, 0xae, 0x05, 0xdf, 0x29, 0x10, 0x67, 0x6c, 0xba, 0xc9, 0xd3, 0x00, 0xe6, 0xcf, 0xe1, 0x9e, 0xa8, 0x2c, 0x63, 0x16, 0x01, 0x3f, 0x58, 0xe2, 0x89, 0xa9, 0x0d, 0x38, 0x34, 0x1b, 0xab, 0x33, 0xff, 0xb0, 0xbb, 0x48, 0x0c, 0x5f, 0xb9, 0xb1, 0xcd, 0x2e, 0xc5, 0xf3, 0xdb, 0x47, 0xe5, 0xa5, 0x9c, 0x77, 0x0a, 0xa6, 0x20, 0x68, 0xfe, 0x7f, 0xc1, 0xad, } func expandKey(key []byte, t1 int) [64]uint16 { l := make([]byte, 128) copy(l, key) var t = len(key) var t8 = (t1 + 7) / 8 var tm = byte(255 % uint(1<<(8+uint(t1)-8*uint(t8)))) for i := len(key); i < 128; i++ { l[i] = piTable[l[i-1]+l[uint8(i-t)]] } l[128-t8] = piTable[l[128-t8]&tm] for i := 127 - t8; i >= 0; i-- { l[i] = piTable[l[i+1]^l[i+t8]] } var k [64]uint16 for i := range k { k[i] = uint16(l[2*i]) + uint16(l[2*i+1])*256 } return k } func (c *rc2Cipher) Encrypt(dst, src []byte) { r0 := binary.LittleEndian.Uint16(src[0:]) r1 := binary.LittleEndian.Uint16(src[2:]) r2 := binary.LittleEndian.Uint16(src[4:]) r3 := binary.LittleEndian.Uint16(src[6:]) var j int for j <= 16 { // mix r0 r0 = r0 + c.k[j] + (r3 & r2) + ((^r3) & r1) r0 = bits.RotateLeft16(r0, 1) j++ // mix r1 r1 = r1 + c.k[j] + (r0 & r3) + ((^r0) & r2) r1 = bits.RotateLeft16(r1, 2) j++ // mix r2 r2 = r2 + c.k[j] + (r1 & r0) + ((^r1) & r3) r2 = bits.RotateLeft16(r2, 3) j++ // mix r3 r3 = r3 + c.k[j] + (r2 & r1) + ((^r2) & r0) r3 = bits.RotateLeft16(r3, 5) j++ } r0 = r0 + c.k[r3&63] r1 = r1 + c.k[r0&63] r2 = r2 + c.k[r1&63] r3 = r3 + c.k[r2&63] for j <= 40 { // mix r0 r0 = r0 + c.k[j] + (r3 & r2) + ((^r3) & r1) r0 = bits.RotateLeft16(r0, 1) j++ // mix r1 r1 = r1 + c.k[j] + (r0 & r3) + ((^r0) & r2) r1 = bits.RotateLeft16(r1, 2) j++ // mix r2 r2 = r2 + c.k[j] + (r1 & r0) + ((^r1) & r3) r2 = bits.RotateLeft16(r2, 3) j++ // mix r3 r3 = r3 + c.k[j] + (r2 & r1) + ((^r2) & r0) r3 = bits.RotateLeft16(r3, 5) j++ } r0 = r0 + c.k[r3&63] r1 = r1 + c.k[r0&63] r2 = r2 + c.k[r1&63] r3 = r3 + c.k[r2&63] for j <= 60 { // mix r0 r0 = r0 + c.k[j] + (r3 & r2) + ((^r3) & r1) r0 = bits.RotateLeft16(r0, 1) j++ // mix r1 r1 = r1 + c.k[j] + (r0 & r3) + ((^r0) & r2) r1 = bits.RotateLeft16(r1, 2) j++ // mix r2 r2 = r2 + c.k[j] + (r1 & r0) + ((^r1) & r3) r2 = bits.RotateLeft16(r2, 3) j++ // mix r3 r3 = r3 + c.k[j] + (r2 & r1) + ((^r2) & r0) r3 = bits.RotateLeft16(r3, 5) j++ } binary.LittleEndian.PutUint16(dst[0:], r0) binary.LittleEndian.PutUint16(dst[2:], r1) binary.LittleEndian.PutUint16(dst[4:], r2) binary.LittleEndian.PutUint16(dst[6:], r3) } func (c *rc2Cipher) Decrypt(dst, src []byte) { r0 := binary.LittleEndian.Uint16(src[0:]) r1 := binary.LittleEndian.Uint16(src[2:]) r2 := binary.LittleEndian.Uint16(src[4:]) r3 := binary.LittleEndian.Uint16(src[6:]) j := 63 for j >= 44 { // unmix r3 r3 = bits.RotateLeft16(r3, 16-5) r3 = r3 - c.k[j] - (r2 & r1) - ((^r2) & r0) j-- // unmix r2 r2 = bits.RotateLeft16(r2, 16-3) r2 = r2 - c.k[j] - (r1 & r0) - ((^r1) & r3) j-- // unmix r1 r1 = bits.RotateLeft16(r1, 16-2) r1 = r1 - c.k[j] - (r0 & r3) - ((^r0) & r2) j-- // unmix r0 r0 = bits.RotateLeft16(r0, 16-1) r0 = r0 - c.k[j] - (r3 & r2) - ((^r3) & r1) j-- } r3 = r3 - c.k[r2&63] r2 = r2 - c.k[r1&63] r1 = r1 - c.k[r0&63] r0 = r0 - c.k[r3&63] for j >= 20 { // unmix r3 r3 = bits.RotateLeft16(r3, 16-5) r3 = r3 - c.k[j] - (r2 & r1) - ((^r2) & r0) j-- // unmix r2 r2 = bits.RotateLeft16(r2, 16-3) r2 = r2 - c.k[j] - (r1 & r0) - ((^r1) & r3) j-- // unmix r1 r1 = bits.RotateLeft16(r1, 16-2) r1 = r1 - c.k[j] - (r0 & r3) - ((^r0) & r2) j-- // unmix r0 r0 = bits.RotateLeft16(r0, 16-1) r0 = r0 - c.k[j] - (r3 & r2) - ((^r3) & r1) j-- } r3 = r3 - c.k[r2&63] r2 = r2 - c.k[r1&63] r1 = r1 - c.k[r0&63] r0 = r0 - c.k[r3&63] for j >= 0 { // unmix r3 r3 = bits.RotateLeft16(r3, 16-5) r3 = r3 - c.k[j] - (r2 & r1) - ((^r2) & r0) j-- // unmix r2 r2 = bits.RotateLeft16(r2, 16-3) r2 = r2 - c.k[j] - (r1 & r0) - ((^r1) & r3) j-- // unmix r1 r1 = bits.RotateLeft16(r1, 16-2) r1 = r1 - c.k[j] - (r0 & r3) - ((^r0) & r2) j-- // unmix r0 r0 = bits.RotateLeft16(r0, 16-1) r0 = r0 - c.k[j] - (r3 & r2) - ((^r3) & r1) j-- } binary.LittleEndian.PutUint16(dst[0:], r0) binary.LittleEndian.PutUint16(dst[2:], r1) binary.LittleEndian.PutUint16(dst[4:], r2) binary.LittleEndian.PutUint16(dst[6:], r3) }
crypto/pkcs12/internal/rc2/rc2.go/0
{ "file_path": "crypto/pkcs12/internal/rc2/rc2.go", "repo_id": "crypto", "token_count": 3945 }
10
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build amd64 && !purego && gc // This code was translated into a form compatible with 6a from the public // domain sources in SUPERCOP: https://bench.cr.yp.to/supercop.html // func salsa2020XORKeyStream(out, in *byte, n uint64, nonce, key *byte) // This needs up to 64 bytes at 360(R12); hence the non-obvious frame size. TEXT ·salsa2020XORKeyStream(SB),0,$456-40 // frame = 424 + 32 byte alignment MOVQ out+0(FP),DI MOVQ in+8(FP),SI MOVQ n+16(FP),DX MOVQ nonce+24(FP),CX MOVQ key+32(FP),R8 MOVQ SP,R12 ADDQ $31, R12 ANDQ $~31, R12 MOVQ DX,R9 MOVQ CX,DX MOVQ R8,R10 CMPQ R9,$0 JBE DONE START: MOVL 20(R10),CX MOVL 0(R10),R8 MOVL 0(DX),AX MOVL 16(R10),R11 MOVL CX,0(R12) MOVL R8, 4 (R12) MOVL AX, 8 (R12) MOVL R11, 12 (R12) MOVL 8(DX),CX MOVL 24(R10),R8 MOVL 4(R10),AX MOVL 4(DX),R11 MOVL CX,16(R12) MOVL R8, 20 (R12) MOVL AX, 24 (R12) MOVL R11, 28 (R12) MOVL 12(DX),CX MOVL 12(R10),DX MOVL 28(R10),R8 MOVL 8(R10),AX MOVL DX,32(R12) MOVL CX, 36 (R12) MOVL R8, 40 (R12) MOVL AX, 44 (R12) MOVQ $1634760805,DX MOVQ $857760878,CX MOVQ $2036477234,R8 MOVQ $1797285236,AX MOVL DX,48(R12) MOVL CX, 52 (R12) MOVL R8, 56 (R12) MOVL AX, 60 (R12) CMPQ R9,$256 JB BYTESBETWEEN1AND255 MOVOA 48(R12),X0 PSHUFL $0X55,X0,X1 PSHUFL $0XAA,X0,X2 PSHUFL $0XFF,X0,X3 PSHUFL $0X00,X0,X0 MOVOA X1,64(R12) MOVOA X2,80(R12) MOVOA X3,96(R12) MOVOA X0,112(R12) MOVOA 0(R12),X0 PSHUFL $0XAA,X0,X1 PSHUFL $0XFF,X0,X2 PSHUFL $0X00,X0,X3 PSHUFL $0X55,X0,X0 MOVOA X1,128(R12) MOVOA X2,144(R12) MOVOA X3,160(R12) MOVOA X0,176(R12) MOVOA 16(R12),X0 PSHUFL $0XFF,X0,X1 PSHUFL $0X55,X0,X2 PSHUFL $0XAA,X0,X0 MOVOA X1,192(R12) MOVOA X2,208(R12) MOVOA X0,224(R12) MOVOA 32(R12),X0 PSHUFL $0X00,X0,X1 PSHUFL $0XAA,X0,X2 PSHUFL $0XFF,X0,X0 MOVOA X1,240(R12) MOVOA X2,256(R12) MOVOA X0,272(R12) BYTESATLEAST256: MOVL 16(R12),DX MOVL 36 (R12),CX MOVL DX,288(R12) MOVL CX,304(R12) SHLQ $32,CX ADDQ CX,DX ADDQ $1,DX MOVQ DX,CX SHRQ $32,CX MOVL DX, 292 (R12) MOVL CX, 308 (R12) ADDQ $1,DX MOVQ DX,CX SHRQ $32,CX MOVL DX, 296 (R12) MOVL CX, 312 (R12) ADDQ $1,DX MOVQ DX,CX SHRQ $32,CX MOVL DX, 300 (R12) MOVL CX, 316 (R12) ADDQ $1,DX MOVQ DX,CX SHRQ $32,CX MOVL DX,16(R12) MOVL CX, 36 (R12) MOVQ R9,352(R12) MOVQ $20,DX MOVOA 64(R12),X0 MOVOA 80(R12),X1 MOVOA 96(R12),X2 MOVOA 256(R12),X3 MOVOA 272(R12),X4 MOVOA 128(R12),X5 MOVOA 144(R12),X6 MOVOA 176(R12),X7 MOVOA 192(R12),X8 MOVOA 208(R12),X9 MOVOA 224(R12),X10 MOVOA 304(R12),X11 MOVOA 112(R12),X12 MOVOA 160(R12),X13 MOVOA 240(R12),X14 MOVOA 288(R12),X15 MAINLOOP1: MOVOA X1,320(R12) MOVOA X2,336(R12) MOVOA X13,X1 PADDL X12,X1 MOVOA X1,X2 PSLLL $7,X1 PXOR X1,X14 PSRLL $25,X2 PXOR X2,X14 MOVOA X7,X1 PADDL X0,X1 MOVOA X1,X2 PSLLL $7,X1 PXOR X1,X11 PSRLL $25,X2 PXOR X2,X11 MOVOA X12,X1 PADDL X14,X1 MOVOA X1,X2 PSLLL $9,X1 PXOR X1,X15 PSRLL $23,X2 PXOR X2,X15 MOVOA X0,X1 PADDL X11,X1 MOVOA X1,X2 PSLLL $9,X1 PXOR X1,X9 PSRLL $23,X2 PXOR X2,X9 MOVOA X14,X1 PADDL X15,X1 MOVOA X1,X2 PSLLL $13,X1 PXOR X1,X13 PSRLL $19,X2 PXOR X2,X13 MOVOA X11,X1 PADDL X9,X1 MOVOA X1,X2 PSLLL $13,X1 PXOR X1,X7 PSRLL $19,X2 PXOR X2,X7 MOVOA X15,X1 PADDL X13,X1 MOVOA X1,X2 PSLLL $18,X1 PXOR X1,X12 PSRLL $14,X2 PXOR X2,X12 MOVOA 320(R12),X1 MOVOA X12,320(R12) MOVOA X9,X2 PADDL X7,X2 MOVOA X2,X12 PSLLL $18,X2 PXOR X2,X0 PSRLL $14,X12 PXOR X12,X0 MOVOA X5,X2 PADDL X1,X2 MOVOA X2,X12 PSLLL $7,X2 PXOR X2,X3 PSRLL $25,X12 PXOR X12,X3 MOVOA 336(R12),X2 MOVOA X0,336(R12) MOVOA X6,X0 PADDL X2,X0 MOVOA X0,X12 PSLLL $7,X0 PXOR X0,X4 PSRLL $25,X12 PXOR X12,X4 MOVOA X1,X0 PADDL X3,X0 MOVOA X0,X12 PSLLL $9,X0 PXOR X0,X10 PSRLL $23,X12 PXOR X12,X10 MOVOA X2,X0 PADDL X4,X0 MOVOA X0,X12 PSLLL $9,X0 PXOR X0,X8 PSRLL $23,X12 PXOR X12,X8 MOVOA X3,X0 PADDL X10,X0 MOVOA X0,X12 PSLLL $13,X0 PXOR X0,X5 PSRLL $19,X12 PXOR X12,X5 MOVOA X4,X0 PADDL X8,X0 MOVOA X0,X12 PSLLL $13,X0 PXOR X0,X6 PSRLL $19,X12 PXOR X12,X6 MOVOA X10,X0 PADDL X5,X0 MOVOA X0,X12 PSLLL $18,X0 PXOR X0,X1 PSRLL $14,X12 PXOR X12,X1 MOVOA 320(R12),X0 MOVOA X1,320(R12) MOVOA X4,X1 PADDL X0,X1 MOVOA X1,X12 PSLLL $7,X1 PXOR X1,X7 PSRLL $25,X12 PXOR X12,X7 MOVOA X8,X1 PADDL X6,X1 MOVOA X1,X12 PSLLL $18,X1 PXOR X1,X2 PSRLL $14,X12 PXOR X12,X2 MOVOA 336(R12),X12 MOVOA X2,336(R12) MOVOA X14,X1 PADDL X12,X1 MOVOA X1,X2 PSLLL $7,X1 PXOR X1,X5 PSRLL $25,X2 PXOR X2,X5 MOVOA X0,X1 PADDL X7,X1 MOVOA X1,X2 PSLLL $9,X1 PXOR X1,X10 PSRLL $23,X2 PXOR X2,X10 MOVOA X12,X1 PADDL X5,X1 MOVOA X1,X2 PSLLL $9,X1 PXOR X1,X8 PSRLL $23,X2 PXOR X2,X8 MOVOA X7,X1 PADDL X10,X1 MOVOA X1,X2 PSLLL $13,X1 PXOR X1,X4 PSRLL $19,X2 PXOR X2,X4 MOVOA X5,X1 PADDL X8,X1 MOVOA X1,X2 PSLLL $13,X1 PXOR X1,X14 PSRLL $19,X2 PXOR X2,X14 MOVOA X10,X1 PADDL X4,X1 MOVOA X1,X2 PSLLL $18,X1 PXOR X1,X0 PSRLL $14,X2 PXOR X2,X0 MOVOA 320(R12),X1 MOVOA X0,320(R12) MOVOA X8,X0 PADDL X14,X0 MOVOA X0,X2 PSLLL $18,X0 PXOR X0,X12 PSRLL $14,X2 PXOR X2,X12 MOVOA X11,X0 PADDL X1,X0 MOVOA X0,X2 PSLLL $7,X0 PXOR X0,X6 PSRLL $25,X2 PXOR X2,X6 MOVOA 336(R12),X2 MOVOA X12,336(R12) MOVOA X3,X0 PADDL X2,X0 MOVOA X0,X12 PSLLL $7,X0 PXOR X0,X13 PSRLL $25,X12 PXOR X12,X13 MOVOA X1,X0 PADDL X6,X0 MOVOA X0,X12 PSLLL $9,X0 PXOR X0,X15 PSRLL $23,X12 PXOR X12,X15 MOVOA X2,X0 PADDL X13,X0 MOVOA X0,X12 PSLLL $9,X0 PXOR X0,X9 PSRLL $23,X12 PXOR X12,X9 MOVOA X6,X0 PADDL X15,X0 MOVOA X0,X12 PSLLL $13,X0 PXOR X0,X11 PSRLL $19,X12 PXOR X12,X11 MOVOA X13,X0 PADDL X9,X0 MOVOA X0,X12 PSLLL $13,X0 PXOR X0,X3 PSRLL $19,X12 PXOR X12,X3 MOVOA X15,X0 PADDL X11,X0 MOVOA X0,X12 PSLLL $18,X0 PXOR X0,X1 PSRLL $14,X12 PXOR X12,X1 MOVOA X9,X0 PADDL X3,X0 MOVOA X0,X12 PSLLL $18,X0 PXOR X0,X2 PSRLL $14,X12 PXOR X12,X2 MOVOA 320(R12),X12 MOVOA 336(R12),X0 SUBQ $2,DX JA MAINLOOP1 PADDL 112(R12),X12 PADDL 176(R12),X7 PADDL 224(R12),X10 PADDL 272(R12),X4 MOVD X12,DX MOVD X7,CX MOVD X10,R8 MOVD X4,R9 PSHUFL $0X39,X12,X12 PSHUFL $0X39,X7,X7 PSHUFL $0X39,X10,X10 PSHUFL $0X39,X4,X4 XORL 0(SI),DX XORL 4(SI),CX XORL 8(SI),R8 XORL 12(SI),R9 MOVL DX,0(DI) MOVL CX,4(DI) MOVL R8,8(DI) MOVL R9,12(DI) MOVD X12,DX MOVD X7,CX MOVD X10,R8 MOVD X4,R9 PSHUFL $0X39,X12,X12 PSHUFL $0X39,X7,X7 PSHUFL $0X39,X10,X10 PSHUFL $0X39,X4,X4 XORL 64(SI),DX XORL 68(SI),CX XORL 72(SI),R8 XORL 76(SI),R9 MOVL DX,64(DI) MOVL CX,68(DI) MOVL R8,72(DI) MOVL R9,76(DI) MOVD X12,DX MOVD X7,CX MOVD X10,R8 MOVD X4,R9 PSHUFL $0X39,X12,X12 PSHUFL $0X39,X7,X7 PSHUFL $0X39,X10,X10 PSHUFL $0X39,X4,X4 XORL 128(SI),DX XORL 132(SI),CX XORL 136(SI),R8 XORL 140(SI),R9 MOVL DX,128(DI) MOVL CX,132(DI) MOVL R8,136(DI) MOVL R9,140(DI) MOVD X12,DX MOVD X7,CX MOVD X10,R8 MOVD X4,R9 XORL 192(SI),DX XORL 196(SI),CX XORL 200(SI),R8 XORL 204(SI),R9 MOVL DX,192(DI) MOVL CX,196(DI) MOVL R8,200(DI) MOVL R9,204(DI) PADDL 240(R12),X14 PADDL 64(R12),X0 PADDL 128(R12),X5 PADDL 192(R12),X8 MOVD X14,DX MOVD X0,CX MOVD X5,R8 MOVD X8,R9 PSHUFL $0X39,X14,X14 PSHUFL $0X39,X0,X0 PSHUFL $0X39,X5,X5 PSHUFL $0X39,X8,X8 XORL 16(SI),DX XORL 20(SI),CX XORL 24(SI),R8 XORL 28(SI),R9 MOVL DX,16(DI) MOVL CX,20(DI) MOVL R8,24(DI) MOVL R9,28(DI) MOVD X14,DX MOVD X0,CX MOVD X5,R8 MOVD X8,R9 PSHUFL $0X39,X14,X14 PSHUFL $0X39,X0,X0 PSHUFL $0X39,X5,X5 PSHUFL $0X39,X8,X8 XORL 80(SI),DX XORL 84(SI),CX XORL 88(SI),R8 XORL 92(SI),R9 MOVL DX,80(DI) MOVL CX,84(DI) MOVL R8,88(DI) MOVL R9,92(DI) MOVD X14,DX MOVD X0,CX MOVD X5,R8 MOVD X8,R9 PSHUFL $0X39,X14,X14 PSHUFL $0X39,X0,X0 PSHUFL $0X39,X5,X5 PSHUFL $0X39,X8,X8 XORL 144(SI),DX XORL 148(SI),CX XORL 152(SI),R8 XORL 156(SI),R9 MOVL DX,144(DI) MOVL CX,148(DI) MOVL R8,152(DI) MOVL R9,156(DI) MOVD X14,DX MOVD X0,CX MOVD X5,R8 MOVD X8,R9 XORL 208(SI),DX XORL 212(SI),CX XORL 216(SI),R8 XORL 220(SI),R9 MOVL DX,208(DI) MOVL CX,212(DI) MOVL R8,216(DI) MOVL R9,220(DI) PADDL 288(R12),X15 PADDL 304(R12),X11 PADDL 80(R12),X1 PADDL 144(R12),X6 MOVD X15,DX MOVD X11,CX MOVD X1,R8 MOVD X6,R9 PSHUFL $0X39,X15,X15 PSHUFL $0X39,X11,X11 PSHUFL $0X39,X1,X1 PSHUFL $0X39,X6,X6 XORL 32(SI),DX XORL 36(SI),CX XORL 40(SI),R8 XORL 44(SI),R9 MOVL DX,32(DI) MOVL CX,36(DI) MOVL R8,40(DI) MOVL R9,44(DI) MOVD X15,DX MOVD X11,CX MOVD X1,R8 MOVD X6,R9 PSHUFL $0X39,X15,X15 PSHUFL $0X39,X11,X11 PSHUFL $0X39,X1,X1 PSHUFL $0X39,X6,X6 XORL 96(SI),DX XORL 100(SI),CX XORL 104(SI),R8 XORL 108(SI),R9 MOVL DX,96(DI) MOVL CX,100(DI) MOVL R8,104(DI) MOVL R9,108(DI) MOVD X15,DX MOVD X11,CX MOVD X1,R8 MOVD X6,R9 PSHUFL $0X39,X15,X15 PSHUFL $0X39,X11,X11 PSHUFL $0X39,X1,X1 PSHUFL $0X39,X6,X6 XORL 160(SI),DX XORL 164(SI),CX XORL 168(SI),R8 XORL 172(SI),R9 MOVL DX,160(DI) MOVL CX,164(DI) MOVL R8,168(DI) MOVL R9,172(DI) MOVD X15,DX MOVD X11,CX MOVD X1,R8 MOVD X6,R9 XORL 224(SI),DX XORL 228(SI),CX XORL 232(SI),R8 XORL 236(SI),R9 MOVL DX,224(DI) MOVL CX,228(DI) MOVL R8,232(DI) MOVL R9,236(DI) PADDL 160(R12),X13 PADDL 208(R12),X9 PADDL 256(R12),X3 PADDL 96(R12),X2 MOVD X13,DX MOVD X9,CX MOVD X3,R8 MOVD X2,R9 PSHUFL $0X39,X13,X13 PSHUFL $0X39,X9,X9 PSHUFL $0X39,X3,X3 PSHUFL $0X39,X2,X2 XORL 48(SI),DX XORL 52(SI),CX XORL 56(SI),R8 XORL 60(SI),R9 MOVL DX,48(DI) MOVL CX,52(DI) MOVL R8,56(DI) MOVL R9,60(DI) MOVD X13,DX MOVD X9,CX MOVD X3,R8 MOVD X2,R9 PSHUFL $0X39,X13,X13 PSHUFL $0X39,X9,X9 PSHUFL $0X39,X3,X3 PSHUFL $0X39,X2,X2 XORL 112(SI),DX XORL 116(SI),CX XORL 120(SI),R8 XORL 124(SI),R9 MOVL DX,112(DI) MOVL CX,116(DI) MOVL R8,120(DI) MOVL R9,124(DI) MOVD X13,DX MOVD X9,CX MOVD X3,R8 MOVD X2,R9 PSHUFL $0X39,X13,X13 PSHUFL $0X39,X9,X9 PSHUFL $0X39,X3,X3 PSHUFL $0X39,X2,X2 XORL 176(SI),DX XORL 180(SI),CX XORL 184(SI),R8 XORL 188(SI),R9 MOVL DX,176(DI) MOVL CX,180(DI) MOVL R8,184(DI) MOVL R9,188(DI) MOVD X13,DX MOVD X9,CX MOVD X3,R8 MOVD X2,R9 XORL 240(SI),DX XORL 244(SI),CX XORL 248(SI),R8 XORL 252(SI),R9 MOVL DX,240(DI) MOVL CX,244(DI) MOVL R8,248(DI) MOVL R9,252(DI) MOVQ 352(R12),R9 SUBQ $256,R9 ADDQ $256,SI ADDQ $256,DI CMPQ R9,$256 JAE BYTESATLEAST256 CMPQ R9,$0 JBE DONE BYTESBETWEEN1AND255: CMPQ R9,$64 JAE NOCOPY MOVQ DI,DX LEAQ 360(R12),DI MOVQ R9,CX REP; MOVSB LEAQ 360(R12),DI LEAQ 360(R12),SI NOCOPY: MOVQ R9,352(R12) MOVOA 48(R12),X0 MOVOA 0(R12),X1 MOVOA 16(R12),X2 MOVOA 32(R12),X3 MOVOA X1,X4 MOVQ $20,CX MAINLOOP2: PADDL X0,X4 MOVOA X0,X5 MOVOA X4,X6 PSLLL $7,X4 PSRLL $25,X6 PXOR X4,X3 PXOR X6,X3 PADDL X3,X5 MOVOA X3,X4 MOVOA X5,X6 PSLLL $9,X5 PSRLL $23,X6 PXOR X5,X2 PSHUFL $0X93,X3,X3 PXOR X6,X2 PADDL X2,X4 MOVOA X2,X5 MOVOA X4,X6 PSLLL $13,X4 PSRLL $19,X6 PXOR X4,X1 PSHUFL $0X4E,X2,X2 PXOR X6,X1 PADDL X1,X5 MOVOA X3,X4 MOVOA X5,X6 PSLLL $18,X5 PSRLL $14,X6 PXOR X5,X0 PSHUFL $0X39,X1,X1 PXOR X6,X0 PADDL X0,X4 MOVOA X0,X5 MOVOA X4,X6 PSLLL $7,X4 PSRLL $25,X6 PXOR X4,X1 PXOR X6,X1 PADDL X1,X5 MOVOA X1,X4 MOVOA X5,X6 PSLLL $9,X5 PSRLL $23,X6 PXOR X5,X2 PSHUFL $0X93,X1,X1 PXOR X6,X2 PADDL X2,X4 MOVOA X2,X5 MOVOA X4,X6 PSLLL $13,X4 PSRLL $19,X6 PXOR X4,X3 PSHUFL $0X4E,X2,X2 PXOR X6,X3 PADDL X3,X5 MOVOA X1,X4 MOVOA X5,X6 PSLLL $18,X5 PSRLL $14,X6 PXOR X5,X0 PSHUFL $0X39,X3,X3 PXOR X6,X0 PADDL X0,X4 MOVOA X0,X5 MOVOA X4,X6 PSLLL $7,X4 PSRLL $25,X6 PXOR X4,X3 PXOR X6,X3 PADDL X3,X5 MOVOA X3,X4 MOVOA X5,X6 PSLLL $9,X5 PSRLL $23,X6 PXOR X5,X2 PSHUFL $0X93,X3,X3 PXOR X6,X2 PADDL X2,X4 MOVOA X2,X5 MOVOA X4,X6 PSLLL $13,X4 PSRLL $19,X6 PXOR X4,X1 PSHUFL $0X4E,X2,X2 PXOR X6,X1 PADDL X1,X5 MOVOA X3,X4 MOVOA X5,X6 PSLLL $18,X5 PSRLL $14,X6 PXOR X5,X0 PSHUFL $0X39,X1,X1 PXOR X6,X0 PADDL X0,X4 MOVOA X0,X5 MOVOA X4,X6 PSLLL $7,X4 PSRLL $25,X6 PXOR X4,X1 PXOR X6,X1 PADDL X1,X5 MOVOA X1,X4 MOVOA X5,X6 PSLLL $9,X5 PSRLL $23,X6 PXOR X5,X2 PSHUFL $0X93,X1,X1 PXOR X6,X2 PADDL X2,X4 MOVOA X2,X5 MOVOA X4,X6 PSLLL $13,X4 PSRLL $19,X6 PXOR X4,X3 PSHUFL $0X4E,X2,X2 PXOR X6,X3 SUBQ $4,CX PADDL X3,X5 MOVOA X1,X4 MOVOA X5,X6 PSLLL $18,X5 PXOR X7,X7 PSRLL $14,X6 PXOR X5,X0 PSHUFL $0X39,X3,X3 PXOR X6,X0 JA MAINLOOP2 PADDL 48(R12),X0 PADDL 0(R12),X1 PADDL 16(R12),X2 PADDL 32(R12),X3 MOVD X0,CX MOVD X1,R8 MOVD X2,R9 MOVD X3,AX PSHUFL $0X39,X0,X0 PSHUFL $0X39,X1,X1 PSHUFL $0X39,X2,X2 PSHUFL $0X39,X3,X3 XORL 0(SI),CX XORL 48(SI),R8 XORL 32(SI),R9 XORL 16(SI),AX MOVL CX,0(DI) MOVL R8,48(DI) MOVL R9,32(DI) MOVL AX,16(DI) MOVD X0,CX MOVD X1,R8 MOVD X2,R9 MOVD X3,AX PSHUFL $0X39,X0,X0 PSHUFL $0X39,X1,X1 PSHUFL $0X39,X2,X2 PSHUFL $0X39,X3,X3 XORL 20(SI),CX XORL 4(SI),R8 XORL 52(SI),R9 XORL 36(SI),AX MOVL CX,20(DI) MOVL R8,4(DI) MOVL R9,52(DI) MOVL AX,36(DI) MOVD X0,CX MOVD X1,R8 MOVD X2,R9 MOVD X3,AX PSHUFL $0X39,X0,X0 PSHUFL $0X39,X1,X1 PSHUFL $0X39,X2,X2 PSHUFL $0X39,X3,X3 XORL 40(SI),CX XORL 24(SI),R8 XORL 8(SI),R9 XORL 56(SI),AX MOVL CX,40(DI) MOVL R8,24(DI) MOVL R9,8(DI) MOVL AX,56(DI) MOVD X0,CX MOVD X1,R8 MOVD X2,R9 MOVD X3,AX XORL 60(SI),CX XORL 44(SI),R8 XORL 28(SI),R9 XORL 12(SI),AX MOVL CX,60(DI) MOVL R8,44(DI) MOVL R9,28(DI) MOVL AX,12(DI) MOVQ 352(R12),R9 MOVL 16(R12),CX MOVL 36 (R12),R8 ADDQ $1,CX SHLQ $32,R8 ADDQ R8,CX MOVQ CX,R8 SHRQ $32,R8 MOVL CX,16(R12) MOVL R8, 36 (R12) CMPQ R9,$64 JA BYTESATLEAST65 JAE BYTESATLEAST64 MOVQ DI,SI MOVQ DX,DI MOVQ R9,CX REP; MOVSB BYTESATLEAST64: DONE: RET BYTESATLEAST65: SUBQ $64,R9 ADDQ $64,DI ADDQ $64,SI JMP BYTESBETWEEN1AND255
crypto/salsa20/salsa/salsa20_amd64.s/0
{ "file_path": "crypto/salsa20/salsa/salsa20_amd64.s", "repo_id": "crypto", "token_count": 9767 }
11
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package agent import ( "bytes" "crypto/rand" "crypto/subtle" "errors" "fmt" "sync" "time" "golang.org/x/crypto/ssh" ) type privKey struct { signer ssh.Signer comment string expire *time.Time } type keyring struct { mu sync.Mutex keys []privKey locked bool passphrase []byte } var errLocked = errors.New("agent: locked") // NewKeyring returns an Agent that holds keys in memory. It is safe // for concurrent use by multiple goroutines. func NewKeyring() Agent { return &keyring{} } // RemoveAll removes all identities. func (r *keyring) RemoveAll() error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } r.keys = nil return nil } // removeLocked does the actual key removal. The caller must already be holding the // keyring mutex. func (r *keyring) removeLocked(want []byte) error { found := false for i := 0; i < len(r.keys); { if bytes.Equal(r.keys[i].signer.PublicKey().Marshal(), want) { found = true r.keys[i] = r.keys[len(r.keys)-1] r.keys = r.keys[:len(r.keys)-1] continue } else { i++ } } if !found { return errors.New("agent: key not found") } return nil } // Remove removes all identities with the given public key. func (r *keyring) Remove(key ssh.PublicKey) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } return r.removeLocked(key.Marshal()) } // Lock locks the agent. Sign and Remove will fail, and List will return an empty list. func (r *keyring) Lock(passphrase []byte) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } r.locked = true r.passphrase = passphrase return nil } // Unlock undoes the effect of Lock func (r *keyring) Unlock(passphrase []byte) error { r.mu.Lock() defer r.mu.Unlock() if !r.locked { return errors.New("agent: not locked") } if 1 != subtle.ConstantTimeCompare(passphrase, r.passphrase) { return fmt.Errorf("agent: incorrect passphrase") } r.locked = false r.passphrase = nil return nil } // expireKeysLocked removes expired keys from the keyring. If a key was added // with a lifetimesecs contraint and seconds >= lifetimesecs seconds have // elapsed, it is removed. The caller *must* be holding the keyring mutex. func (r *keyring) expireKeysLocked() { for _, k := range r.keys { if k.expire != nil && time.Now().After(*k.expire) { r.removeLocked(k.signer.PublicKey().Marshal()) } } } // List returns the identities known to the agent. func (r *keyring) List() ([]*Key, error) { r.mu.Lock() defer r.mu.Unlock() if r.locked { // section 2.7: locked agents return empty. return nil, nil } r.expireKeysLocked() var ids []*Key for _, k := range r.keys { pub := k.signer.PublicKey() ids = append(ids, &Key{ Format: pub.Type(), Blob: pub.Marshal(), Comment: k.comment}) } return ids, nil } // Insert adds a private key to the keyring. If a certificate // is given, that certificate is added as public key. Note that // any constraints given are ignored. func (r *keyring) Add(key AddedKey) error { r.mu.Lock() defer r.mu.Unlock() if r.locked { return errLocked } signer, err := ssh.NewSignerFromKey(key.PrivateKey) if err != nil { return err } if cert := key.Certificate; cert != nil { signer, err = ssh.NewCertSigner(cert, signer) if err != nil { return err } } p := privKey{ signer: signer, comment: key.Comment, } if key.LifetimeSecs > 0 { t := time.Now().Add(time.Duration(key.LifetimeSecs) * time.Second) p.expire = &t } r.keys = append(r.keys, p) return nil } // Sign returns a signature for the data. func (r *keyring) Sign(key ssh.PublicKey, data []byte) (*ssh.Signature, error) { return r.SignWithFlags(key, data, 0) } func (r *keyring) SignWithFlags(key ssh.PublicKey, data []byte, flags SignatureFlags) (*ssh.Signature, error) { r.mu.Lock() defer r.mu.Unlock() if r.locked { return nil, errLocked } r.expireKeysLocked() wanted := key.Marshal() for _, k := range r.keys { if bytes.Equal(k.signer.PublicKey().Marshal(), wanted) { if flags == 0 { return k.signer.Sign(rand.Reader, data) } else { if algorithmSigner, ok := k.signer.(ssh.AlgorithmSigner); !ok { return nil, fmt.Errorf("agent: signature does not support non-default signature algorithm: %T", k.signer) } else { var algorithm string switch flags { case SignatureFlagRsaSha256: algorithm = ssh.KeyAlgoRSASHA256 case SignatureFlagRsaSha512: algorithm = ssh.KeyAlgoRSASHA512 default: return nil, fmt.Errorf("agent: unsupported signature flags: %d", flags) } return algorithmSigner.SignWithAlgorithm(rand.Reader, data, algorithm) } } } } return nil, errors.New("not found") } // Signers returns signers for all the known keys. func (r *keyring) Signers() ([]ssh.Signer, error) { r.mu.Lock() defer r.mu.Unlock() if r.locked { return nil, errLocked } r.expireKeysLocked() s := make([]ssh.Signer, 0, len(r.keys)) for _, k := range r.keys { s = append(s, k.signer) } return s, nil } // The keyring does not support any extensions func (r *keyring) Extension(extensionType string, contents []byte) ([]byte, error) { return nil, ErrExtensionUnsupported }
crypto/ssh/agent/keyring.go/0
{ "file_path": "crypto/ssh/agent/keyring.go", "repo_id": "crypto", "token_count": 2086 }
12
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh import ( "bytes" "crypto/rand" "errors" "fmt" "net" "strings" "testing" ) func TestClientVersion(t *testing.T) { for _, tt := range []struct { name string version string multiLine string wantErr bool }{ { name: "default version", version: packageVersion, }, { name: "custom version", version: "SSH-2.0-CustomClientVersionString", }, { name: "good multi line version", version: packageVersion, multiLine: strings.Repeat("ignored\r\n", 20), }, { name: "bad multi line version", version: packageVersion, multiLine: "bad multi line version", wantErr: true, }, { name: "long multi line version", version: packageVersion, multiLine: strings.Repeat("long multi line version\r\n", 50)[:256], wantErr: true, }, } { t.Run(tt.name, func(t *testing.T) { c1, c2, err := netPipe() if err != nil { t.Fatalf("netPipe: %v", err) } defer c1.Close() defer c2.Close() go func() { if tt.multiLine != "" { c1.Write([]byte(tt.multiLine)) } NewClientConn(c1, "", &ClientConfig{ ClientVersion: tt.version, HostKeyCallback: InsecureIgnoreHostKey(), }) c1.Close() }() conf := &ServerConfig{NoClientAuth: true} conf.AddHostKey(testSigners["rsa"]) conn, _, _, err := NewServerConn(c2, conf) if err == nil == tt.wantErr { t.Fatalf("got err %v; wantErr %t", err, tt.wantErr) } if tt.wantErr { // Don't verify the version on an expected error. return } if got := string(conn.ClientVersion()); got != tt.version { t.Fatalf("got %q; want %q", got, tt.version) } }) } } func TestHostKeyCheck(t *testing.T) { for _, tt := range []struct { name string wantError string key PublicKey }{ {"no callback", "must specify HostKeyCallback", nil}, {"correct key", "", testSigners["rsa"].PublicKey()}, {"mismatch", "mismatch", testSigners["ecdsa"].PublicKey()}, } { c1, c2, err := netPipe() if err != nil { t.Fatalf("netPipe: %v", err) } defer c1.Close() defer c2.Close() serverConf := &ServerConfig{ NoClientAuth: true, } serverConf.AddHostKey(testSigners["rsa"]) go NewServerConn(c1, serverConf) clientConf := ClientConfig{ User: "user", } if tt.key != nil { clientConf.HostKeyCallback = FixedHostKey(tt.key) } _, _, _, err = NewClientConn(c2, "", &clientConf) if err != nil { if tt.wantError == "" || !strings.Contains(err.Error(), tt.wantError) { t.Errorf("%s: got error %q, missing %q", tt.name, err.Error(), tt.wantError) } } else if tt.wantError != "" { t.Errorf("%s: succeeded, but want error string %q", tt.name, tt.wantError) } } } func TestVerifyHostKeySignature(t *testing.T) { for _, tt := range []struct { key string signAlgo string verifyAlgo string wantError string }{ {"rsa", KeyAlgoRSA, KeyAlgoRSA, ""}, {"rsa", KeyAlgoRSASHA256, KeyAlgoRSASHA256, ""}, {"rsa", KeyAlgoRSA, KeyAlgoRSASHA512, `ssh: invalid signature algorithm "ssh-rsa", expected "rsa-sha2-512"`}, {"ed25519", KeyAlgoED25519, KeyAlgoED25519, ""}, } { key := testSigners[tt.key].PublicKey() s, ok := testSigners[tt.key].(AlgorithmSigner) if !ok { t.Fatalf("needed an AlgorithmSigner") } sig, err := s.SignWithAlgorithm(rand.Reader, []byte("test"), tt.signAlgo) if err != nil { t.Fatalf("couldn't sign: %q", err) } b := bytes.Buffer{} writeString(&b, []byte(sig.Format)) writeString(&b, sig.Blob) result := kexResult{Signature: b.Bytes(), H: []byte("test")} err = verifyHostKeySignature(key, tt.verifyAlgo, &result) if err != nil { if tt.wantError == "" || !strings.Contains(err.Error(), tt.wantError) { t.Errorf("got error %q, expecting %q", err.Error(), tt.wantError) } } else if tt.wantError != "" { t.Errorf("succeeded, but want error string %q", tt.wantError) } } } func TestBannerCallback(t *testing.T) { c1, c2, err := netPipe() if err != nil { t.Fatalf("netPipe: %v", err) } defer c1.Close() defer c2.Close() serverConf := &ServerConfig{ PasswordCallback: func(conn ConnMetadata, password []byte) (*Permissions, error) { return &Permissions{}, nil }, BannerCallback: func(conn ConnMetadata) string { return "Hello World" }, } serverConf.AddHostKey(testSigners["rsa"]) go NewServerConn(c1, serverConf) var receivedBanner string var bannerCount int clientConf := ClientConfig{ Auth: []AuthMethod{ Password("123"), }, User: "user", HostKeyCallback: InsecureIgnoreHostKey(), BannerCallback: func(message string) error { bannerCount++ receivedBanner = message return nil }, } _, _, _, err = NewClientConn(c2, "", &clientConf) if err != nil { t.Fatal(err) } if bannerCount != 1 { t.Errorf("got %d banners; want 1", bannerCount) } expected := "Hello World" if receivedBanner != expected { t.Fatalf("got %s; want %s", receivedBanner, expected) } } func TestNewClientConn(t *testing.T) { errHostKeyMismatch := errors.New("host key mismatch") for _, tt := range []struct { name string user string simulateHostKeyMismatch HostKeyCallback }{ { name: "good user field for ConnMetadata", user: "testuser", }, { name: "empty user field for ConnMetadata", user: "", }, { name: "host key mismatch", user: "testuser", simulateHostKeyMismatch: func(hostname string, remote net.Addr, key PublicKey) error { return fmt.Errorf("%w: %s", errHostKeyMismatch, bytes.TrimSpace(MarshalAuthorizedKey(key))) }, }, } { t.Run(tt.name, func(t *testing.T) { c1, c2, err := netPipe() if err != nil { t.Fatalf("netPipe: %v", err) } defer c1.Close() defer c2.Close() serverConf := &ServerConfig{ PasswordCallback: func(conn ConnMetadata, password []byte) (*Permissions, error) { return &Permissions{}, nil }, } serverConf.AddHostKey(testSigners["rsa"]) go NewServerConn(c1, serverConf) clientConf := &ClientConfig{ User: tt.user, Auth: []AuthMethod{ Password("testpw"), }, HostKeyCallback: InsecureIgnoreHostKey(), } if tt.simulateHostKeyMismatch != nil { clientConf.HostKeyCallback = tt.simulateHostKeyMismatch } clientConn, _, _, err := NewClientConn(c2, "", clientConf) if err != nil { if tt.simulateHostKeyMismatch != nil && errors.Is(err, errHostKeyMismatch) { return } t.Fatal(err) } if userGot := clientConn.User(); userGot != tt.user { t.Errorf("got user %q; want user %q", userGot, tt.user) } }) } } func TestUnsupportedAlgorithm(t *testing.T) { for _, tt := range []struct { name string config Config wantError string }{ { "unsupported KEX", Config{ KeyExchanges: []string{"unsupported"}, }, "no common algorithm", }, { "unsupported and supported KEXs", Config{ KeyExchanges: []string{"unsupported", kexAlgoCurve25519SHA256}, }, "", }, { "unsupported cipher", Config{ Ciphers: []string{"unsupported"}, }, "no common algorithm", }, { "unsupported and supported ciphers", Config{ Ciphers: []string{"unsupported", chacha20Poly1305ID}, }, "", }, { "unsupported MAC", Config{ MACs: []string{"unsupported"}, // MAC is used for non AAED ciphers. Ciphers: []string{"aes256-ctr"}, }, "no common algorithm", }, { "unsupported and supported MACs", Config{ MACs: []string{"unsupported", "hmac-sha2-256-etm@openssh.com"}, // MAC is used for non AAED ciphers. Ciphers: []string{"aes256-ctr"}, }, "", }, } { t.Run(tt.name, func(t *testing.T) { c1, c2, err := netPipe() if err != nil { t.Fatalf("netPipe: %v", err) } defer c1.Close() defer c2.Close() serverConf := &ServerConfig{ Config: tt.config, PasswordCallback: func(conn ConnMetadata, password []byte) (*Permissions, error) { return &Permissions{}, nil }, } serverConf.AddHostKey(testSigners["rsa"]) go NewServerConn(c1, serverConf) clientConf := &ClientConfig{ User: "testuser", Config: tt.config, Auth: []AuthMethod{ Password("testpw"), }, HostKeyCallback: InsecureIgnoreHostKey(), } _, _, _, err = NewClientConn(c2, "", clientConf) if err != nil { if tt.wantError == "" || !strings.Contains(err.Error(), tt.wantError) { t.Errorf("%s: got error %q, missing %q", tt.name, err.Error(), tt.wantError) } } else if tt.wantError != "" { t.Errorf("%s: succeeded, but want error string %q", tt.name, tt.wantError) } }) } }
crypto/ssh/client_test.go/0
{ "file_path": "crypto/ssh/client_test.go", "repo_id": "crypto", "token_count": 3908 }
13
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssh // Message authentication support import ( "crypto/hmac" "crypto/sha1" "crypto/sha256" "crypto/sha512" "hash" ) type macMode struct { keySize int etm bool new func(key []byte) hash.Hash } // truncatingMAC wraps around a hash.Hash and truncates the output digest to // a given size. type truncatingMAC struct { length int hmac hash.Hash } func (t truncatingMAC) Write(data []byte) (int, error) { return t.hmac.Write(data) } func (t truncatingMAC) Sum(in []byte) []byte { out := t.hmac.Sum(in) return out[:len(in)+t.length] } func (t truncatingMAC) Reset() { t.hmac.Reset() } func (t truncatingMAC) Size() int { return t.length } func (t truncatingMAC) BlockSize() int { return t.hmac.BlockSize() } var macModes = map[string]*macMode{ "hmac-sha2-512-etm@openssh.com": {64, true, func(key []byte) hash.Hash { return hmac.New(sha512.New, key) }}, "hmac-sha2-256-etm@openssh.com": {32, true, func(key []byte) hash.Hash { return hmac.New(sha256.New, key) }}, "hmac-sha2-512": {64, false, func(key []byte) hash.Hash { return hmac.New(sha512.New, key) }}, "hmac-sha2-256": {32, false, func(key []byte) hash.Hash { return hmac.New(sha256.New, key) }}, "hmac-sha1": {20, false, func(key []byte) hash.Hash { return hmac.New(sha1.New, key) }}, "hmac-sha1-96": {20, false, func(key []byte) hash.Hash { return truncatingMAC{12, hmac.New(sha1.New, key)} }}, }
crypto/ssh/mac.go/0
{ "file_path": "crypto/ssh/mac.go", "repo_id": "crypto", "token_count": 647 }
14
// Copyright 2011 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package terminal provides support functions for dealing with terminals, as // commonly found on UNIX systems. // // Deprecated: this package moved to golang.org/x/term. package terminal import ( "io" "golang.org/x/term" ) // EscapeCodes contains escape sequences that can be written to the terminal in // order to achieve different styles of text. type EscapeCodes = term.EscapeCodes // Terminal contains the state for running a VT100 terminal that is capable of // reading lines of input. type Terminal = term.Terminal // NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is // a local terminal, that terminal must first have been put into raw mode. // prompt is a string that is written at the start of each input line (i.e. // "> "). func NewTerminal(c io.ReadWriter, prompt string) *Terminal { return term.NewTerminal(c, prompt) } // ErrPasteIndicator may be returned from ReadLine as the error, in addition // to valid line data. It indicates that bracketed paste mode is enabled and // that the returned line consists only of pasted data. Programs may wish to // interpret pasted data more literally than typed data. var ErrPasteIndicator = term.ErrPasteIndicator // State contains the state of a terminal. type State = term.State // IsTerminal returns whether the given file descriptor is a terminal. func IsTerminal(fd int) bool { return term.IsTerminal(fd) } // ReadPassword reads a line of input from a terminal without local echo. This // is commonly used for inputting passwords and other sensitive data. The slice // returned does not include the \n. func ReadPassword(fd int) ([]byte, error) { return term.ReadPassword(fd) } // MakeRaw puts the terminal connected to the given file descriptor into raw // mode and returns the previous state of the terminal so that it can be // restored. func MakeRaw(fd int) (*State, error) { return term.MakeRaw(fd) } // Restore restores the terminal connected to the given file descriptor to a // previous state. func Restore(fd int, oldState *State) error { return term.Restore(fd, oldState) } // GetState returns the current state of a terminal which may be useful to // restore the terminal after a signal. func GetState(fd int) (*State, error) { return term.GetState(fd) } // GetSize returns the dimensions of the given terminal. func GetSize(fd int) (width, height int, err error) { return term.GetSize(fd) }
crypto/ssh/terminal/terminal.go/0
{ "file_path": "crypto/ssh/terminal/terminal.go", "repo_id": "crypto", "token_count": 699 }
15
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // IMPLEMENTATION NOTE: To avoid a package loop, this file is in three places: // ssh/, ssh/agent, and ssh/test/. It should be kept in sync across all three // instances. package ssh import ( "crypto/rand" "fmt" "golang.org/x/crypto/ssh/testdata" ) var ( testPrivateKeys map[string]interface{} testSigners map[string]Signer testPublicKeys map[string]PublicKey ) func init() { var err error n := len(testdata.PEMBytes) testPrivateKeys = make(map[string]interface{}, n) testSigners = make(map[string]Signer, n) testPublicKeys = make(map[string]PublicKey, n) for t, k := range testdata.PEMBytes { testPrivateKeys[t], err = ParseRawPrivateKey(k) if err != nil { panic(fmt.Sprintf("Unable to parse test key %s: %v", t, err)) } testSigners[t], err = NewSignerFromKey(testPrivateKeys[t]) if err != nil { panic(fmt.Sprintf("Unable to create signer for test key %s: %v", t, err)) } testPublicKeys[t] = testSigners[t].PublicKey() } // Create a cert and sign it for use in tests. testCert := &Certificate{ Nonce: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil ValidPrincipals: []string{"gopher1", "gopher2"}, // increases test coverage ValidAfter: 0, // unix epoch ValidBefore: CertTimeInfinity, // The end of currently representable time. Reserved: []byte{}, // To pass reflect.DeepEqual after marshal & parse, this must be non-nil Key: testPublicKeys["ecdsa"], SignatureKey: testPublicKeys["rsa"], Permissions: Permissions{ CriticalOptions: map[string]string{}, Extensions: map[string]string{}, }, } testCert.SignCert(rand.Reader, testSigners["rsa"]) testPrivateKeys["cert"] = testPrivateKeys["ecdsa"] testSigners["cert"], err = NewCertSigner(testCert, testSigners["ecdsa"]) if err != nil { panic(fmt.Sprintf("Unable to create certificate signer: %v", err)) } }
crypto/ssh/testdata_test.go/0
{ "file_path": "crypto/ssh/testdata_test.go", "repo_id": "crypto", "token_count": 856 }
16
// Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package xts implements the XTS cipher mode as specified in IEEE P1619/D16. // // XTS mode is typically used for disk encryption, which presents a number of // novel problems that make more common modes inapplicable. The disk is // conceptually an array of sectors and we must be able to encrypt and decrypt // a sector in isolation. However, an attacker must not be able to transpose // two sectors of plaintext by transposing their ciphertext. // // XTS wraps a block cipher with Rogaway's XEX mode in order to build a // tweakable block cipher. This allows each sector to have a unique tweak and // effectively create a unique key for each sector. // // XTS does not provide any authentication. An attacker can manipulate the // ciphertext and randomise a block (16 bytes) of the plaintext. This package // does not implement ciphertext-stealing so sectors must be a multiple of 16 // bytes. // // Note that XTS is usually not appropriate for any use besides disk encryption. // Most users should use an AEAD mode like GCM (from crypto/cipher.NewGCM) instead. package xts import ( "crypto/cipher" "encoding/binary" "errors" "sync" "golang.org/x/crypto/internal/alias" ) // Cipher contains an expanded key structure. It is safe for concurrent use if // the underlying block cipher is safe for concurrent use. type Cipher struct { k1, k2 cipher.Block } // blockSize is the block size that the underlying cipher must have. XTS is // only defined for 16-byte ciphers. const blockSize = 16 var tweakPool = sync.Pool{ New: func() interface{} { return new([blockSize]byte) }, } // NewCipher creates a Cipher given a function for creating the underlying // block cipher (which must have a block size of 16 bytes). The key must be // twice the length of the underlying cipher's key. func NewCipher(cipherFunc func([]byte) (cipher.Block, error), key []byte) (c *Cipher, err error) { c = new(Cipher) if c.k1, err = cipherFunc(key[:len(key)/2]); err != nil { return } c.k2, err = cipherFunc(key[len(key)/2:]) if c.k1.BlockSize() != blockSize { err = errors.New("xts: cipher does not have a block size of 16") } return } // Encrypt encrypts a sector of plaintext and puts the result into ciphertext. // Plaintext and ciphertext must overlap entirely or not at all. // Sectors must be a multiple of 16 bytes and less than 2²⁴ bytes. func (c *Cipher) Encrypt(ciphertext, plaintext []byte, sectorNum uint64) { if len(ciphertext) < len(plaintext) { panic("xts: ciphertext is smaller than plaintext") } if len(plaintext)%blockSize != 0 { panic("xts: plaintext is not a multiple of the block size") } if alias.InexactOverlap(ciphertext[:len(plaintext)], plaintext) { panic("xts: invalid buffer overlap") } tweak := tweakPool.Get().(*[blockSize]byte) for i := range tweak { tweak[i] = 0 } binary.LittleEndian.PutUint64(tweak[:8], sectorNum) c.k2.Encrypt(tweak[:], tweak[:]) for len(plaintext) > 0 { for j := range tweak { ciphertext[j] = plaintext[j] ^ tweak[j] } c.k1.Encrypt(ciphertext, ciphertext) for j := range tweak { ciphertext[j] ^= tweak[j] } plaintext = plaintext[blockSize:] ciphertext = ciphertext[blockSize:] mul2(tweak) } tweakPool.Put(tweak) } // Decrypt decrypts a sector of ciphertext and puts the result into plaintext. // Plaintext and ciphertext must overlap entirely or not at all. // Sectors must be a multiple of 16 bytes and less than 2²⁴ bytes. func (c *Cipher) Decrypt(plaintext, ciphertext []byte, sectorNum uint64) { if len(plaintext) < len(ciphertext) { panic("xts: plaintext is smaller than ciphertext") } if len(ciphertext)%blockSize != 0 { panic("xts: ciphertext is not a multiple of the block size") } if alias.InexactOverlap(plaintext[:len(ciphertext)], ciphertext) { panic("xts: invalid buffer overlap") } tweak := tweakPool.Get().(*[blockSize]byte) for i := range tweak { tweak[i] = 0 } binary.LittleEndian.PutUint64(tweak[:8], sectorNum) c.k2.Encrypt(tweak[:], tweak[:]) for len(ciphertext) > 0 { for j := range tweak { plaintext[j] = ciphertext[j] ^ tweak[j] } c.k1.Decrypt(plaintext, plaintext) for j := range tweak { plaintext[j] ^= tweak[j] } plaintext = plaintext[blockSize:] ciphertext = ciphertext[blockSize:] mul2(tweak) } tweakPool.Put(tweak) } // mul2 multiplies tweak by 2 in GF(2¹²⁸) with an irreducible polynomial of // x¹²⁸ + x⁷ + x² + x + 1. func mul2(tweak *[blockSize]byte) { var carryIn byte for j := range tweak { carryOut := tweak[j] >> 7 tweak[j] = (tweak[j] << 1) + carryIn carryIn = carryOut } if carryIn != 0 { // If we have a carry bit then we need to subtract a multiple // of the irreducible polynomial (x¹²⁸ + x⁷ + x² + x + 1). // By dropping the carry bit, we're subtracting the x^128 term // so all that remains is to subtract x⁷ + x² + x + 1. // Subtraction (and addition) in this representation is just // XOR. tweak[0] ^= 1<<7 | 1<<2 | 1<<1 | 1 } }
crypto/xts/xts.go/0
{ "file_path": "crypto/xts/xts.go", "repo_id": "crypto", "token_count": 1772 }
17
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "bytes" "fmt" "hash/fnv" "sort" "strings" ) type graphviz struct { ps []*gvnode b bytes.Buffer h map[string]uint32 // clusters is a map of project name and subgraph object. This can be used // to refer the subgraph by project name. clusters map[string]*gvsubgraph } type gvnode struct { project string version string children []string } // Sort gvnode(s). type byGvnode []gvnode func (n byGvnode) Len() int { return len(n) } func (n byGvnode) Swap(i, j int) { n[i], n[j] = n[j], n[i] } func (n byGvnode) Less(i, j int) bool { return n[i].project < n[j].project } func (g graphviz) New() *graphviz { ga := &graphviz{ ps: []*gvnode{}, h: make(map[string]uint32), clusters: make(map[string]*gvsubgraph), } return ga } func (g *graphviz) output(project string) bytes.Buffer { if project == "" { // Project relations graph. g.b.WriteString("digraph {\n\tnode [shape=box];") for _, gvp := range g.ps { // Create node string g.b.WriteString(fmt.Sprintf("\n\t%d [label=\"%s\"];", gvp.hash(), gvp.label())) } g.createProjectRelations() } else { // Project-Package relations graph. g.b.WriteString("digraph {\n\tnode [shape=box];\n\tcompound=true;\n\tedge [minlen=2];") // Declare all the nodes with labels. for _, gvp := range g.ps { g.b.WriteString(fmt.Sprintf("\n\t%d [label=\"%s\"];", gvp.hash(), gvp.label())) } // Sort the clusters for a consistent output. clusters := sortClusters(g.clusters) // Declare all the subgraphs with labels. for _, gsg := range clusters { g.b.WriteString(fmt.Sprintf("\n\tsubgraph cluster_%d {", gsg.index)) g.b.WriteString(fmt.Sprintf("\n\t\tlabel = \"%s\";", gsg.project)) nhashes := []string{} for _, pkg := range gsg.packages { nhashes = append(nhashes, fmt.Sprint(g.h[pkg])) } g.b.WriteString(fmt.Sprintf("\n\t\t%s;", strings.Join(nhashes, " "))) g.b.WriteString("\n\t}") } g.createProjectPackageRelations(project, clusters) } g.b.WriteString("\n}\n") return g.b } func (g *graphviz) createProjectRelations() { // Store relations to avoid duplication rels := make(map[string]bool) // Create relations for _, dp := range g.ps { for _, bsc := range dp.children { for pr, hsh := range g.h { if isPathPrefix(bsc, pr) { r := fmt.Sprintf("\n\t%d -> %d", g.h[dp.project], hsh) if _, ex := rels[r]; !ex { g.b.WriteString(r + ";") rels[r] = true } } } } } } func (g *graphviz) createProjectPackageRelations(project string, clusters []*gvsubgraph) { // This function takes a child package/project, target project, subgraph meta, from // and to of the edge and write a relation. linkRelation := func(child, project string, meta []string, from, to uint32) { if child == project { // Check if it's a cluster. target, ok := g.clusters[project] if ok { // It's a cluster. Point to the Project Root. Use lhead. meta = append(meta, fmt.Sprintf("lhead=cluster_%d", target.index)) // When the head points to a cluster root, use the first // node in the cluster as to. to = g.h[target.packages[0]] } } if len(meta) > 0 { g.b.WriteString(fmt.Sprintf("\n\t%d -> %d [%s];", from, to, strings.Join(meta, " "))) } else { g.b.WriteString(fmt.Sprintf("\n\t%d -> %d;", from, to)) } } // Create relations from nodes. for _, node := range g.ps { for _, child := range node.children { // Only if it points to the target project, proceed further. if isPathPrefix(child, project) { meta := []string{} from := g.h[node.project] to := g.h[child] linkRelation(child, project, meta, from, to) } } } // Create relations from clusters. for _, cluster := range clusters { for _, child := range cluster.children { // Only if it points to the target project, proceed further. if isPathPrefix(child, project) { meta := []string{fmt.Sprintf("ltail=cluster_%d", cluster.index)} // When the tail is from a cluster, use the first node in the // cluster as from. from := g.h[cluster.packages[0]] to := g.h[child] linkRelation(child, project, meta, from, to) } } } } func (g *graphviz) createNode(project, version string, children []string) { pr := &gvnode{ project: project, version: version, children: children, } g.h[pr.project] = pr.hash() g.ps = append(g.ps, pr) } func (dp gvnode) hash() uint32 { h := fnv.New32a() h.Write([]byte(dp.project)) return h.Sum32() } func (dp gvnode) label() string { label := []string{dp.project} if dp.version != "" { label = append(label, dp.version) } return strings.Join(label, "\\n") } // isPathPrefix ensures that the literal string prefix is a path tree match and // guards against possibilities like this: // // github.com/sdboyer/foo // github.com/sdboyer/foobar/baz // // Verify that prefix is path match and either the input is the same length as // the match (in which case we know they're equal), or that the next character // is a "/". (Import paths are defined to always use "/", not the OS-specific // path separator.) func isPathPrefix(path, pre string) bool { pathlen, prflen := len(path), len(pre) if pathlen < prflen || path[0:prflen] != pre { return false } return prflen == pathlen || strings.Index(path[prflen:], "/") == 0 } // gvsubgraph is a graphviz subgraph with at least one node(package) in it. type gvsubgraph struct { project string // Project root name of a project. packages []string // List of subpackages in the project. index int // Index of the subgraph cluster. This is used to refer the subgraph in the dot file. children []string // Dependencies of the project root package. } func (sg gvsubgraph) hash() uint32 { h := fnv.New32a() h.Write([]byte(sg.project)) return h.Sum32() } // createSubgraph creates a graphviz subgraph with nodes in it. This should only // be created when a project has more than one package. A single package project // should be just a single node. // First nodes are created using the provided packages and their imports. Then // a subgraph is created with all the nodes in it. func (g *graphviz) createSubgraph(project string, packages map[string][]string) { // If there's only a single package and that's the project root, do not // create a subgraph. Just create a node. if children, ok := packages[project]; ok && len(packages) == 1 { g.createNode(project, "", children) return } // Sort and use the packages for consistent output. pkgs := []gvnode{} for name, children := range packages { pkgs = append(pkgs, gvnode{project: name, children: children}) } sort.Sort(byGvnode(pkgs)) subgraphPkgs := []string{} rootChildren := []string{} for _, p := range pkgs { if p.project == project { // Do not create a separate node for the root package. rootChildren = append(rootChildren, p.children...) continue } g.createNode(p.project, "", p.children) subgraphPkgs = append(subgraphPkgs, p.project) } sg := &gvsubgraph{ project: project, packages: subgraphPkgs, index: len(g.clusters), children: rootChildren, } g.h[project] = sg.hash() g.clusters[project] = sg } // sortCluster takes a map of all the clusters and returns a list of cluster // names sorted by the cluster index. func sortClusters(clusters map[string]*gvsubgraph) []*gvsubgraph { result := []*gvsubgraph{} for _, cluster := range clusters { result = append(result, cluster) } sort.Slice(result, func(i, j int) bool { return result[i].index < result[j].index }) return result }
dep/cmd/dep/graphviz.go/0
{ "file_path": "dep/cmd/dep/graphviz.go", "repo_id": "dep", "token_count": 2965 }
18
digraph { node [shape=box]; compound=true; edge [minlen=2]; 552838292 [label="ProjectA/pkgX"]; 569615911 [label="ProjectA/pkgY"]; 2062426895 [label="ProjectB/pkgX"]; 2045649276 [label="ProjectB/pkgY"]; 990902230 [label="ProjectC/pkgX"]; 1007679849 [label="ProjectC/pkgY"]; 957346992 [label="ProjectC/pkgZ"]; subgraph cluster_0 { label = "ProjectA"; 552838292 569615911; } subgraph cluster_1 { label = "ProjectB"; 2062426895 2045649276; } subgraph cluster_2 { label = "ProjectC"; 990902230 1007679849 957346992; } 552838292 -> 957346992; 569615911 -> 990902230; 2045649276 -> 957346992; }
dep/cmd/dep/testdata/graphviz/subgraph1.dot/0
{ "file_path": "dep/cmd/dep/testdata/graphviz/subgraph1.dot", "repo_id": "dep", "token_count": 278 }
19
noverify = ["github.com/sdboyer/deptest"]
dep/cmd/dep/testdata/harness_tests/check/noverify/vendororphans/final/Gopkg.toml/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/check/noverify/vendororphans/final/Gopkg.toml", "repo_id": "dep", "token_count": 18 }
20
{ "commands": [ ["init", "-no-examples"], ["ensure", "-add", "github.com/sdboyer/deptesttres", "github.com/sdboyer/deptesttres/subp"] ], "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptesttres" ] }
dep/cmd/dep/testdata/harness_tests/ensure/add/all-new-double/testcase.json/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/ensure/add/all-new-double/testcase.json", "repo_id": "dep", "token_count": 123 }
21
{ "commands": [ ["ensure", "-add", "github.com/sdboyer/deptesttres@master"] ], "vendor-final": [ "github.com/sdboyer/deptest", "github.com/sdboyer/deptestdos", "github.com/sdboyer/deptesttres" ] }
dep/cmd/dep/testdata/harness_tests/ensure/add/desync/testcase.json/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/ensure/add/desync/testcase.json", "repo_id": "dep", "token_count": 114 }
22
{ "commands": [ ["ensure", "-add", "github.com/sdboyer/deptest"] ], "error-expected": "nothing to -add, github.com/sdboyer/deptest is already in Gopkg.toml and the project's direct imports or required list" }
dep/cmd/dep/testdata/harness_tests/ensure/add/errs/exists/testcase.json/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/ensure/add/errs/exists/testcase.json", "repo_id": "dep", "token_count": 81 }
23
noverify = ["github.com/sdboyer/deptest"]
dep/cmd/dep/testdata/harness_tests/ensure/noverify/hash_mismatch/initial/Gopkg.toml/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/ensure/noverify/hash_mismatch/initial/Gopkg.toml", "repo_id": "dep", "token_count": 18 }
24
ignored = ["github.com/sdboyer/deptest*", "github.com/golang/notexist/samples*"]
dep/cmd/dep/testdata/harness_tests/ensure/pkg-ignored/wildcard-other-root/final/Gopkg.toml/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/ensure/pkg-ignored/wildcard-other-root/final/Gopkg.toml", "repo_id": "dep", "token_count": 34 }
25
Ignore glide config if glide.yaml is malformed and cannot be parsed correctly.
dep/cmd/dep/testdata/harness_tests/init/glide/case4/README.md/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/init/glide/case4/README.md", "repo_id": "dep", "token_count": 19 }
26
[[constraint]] name = "github.com/ChinmayR/deptestglideA" version = "0.6.0"
dep/cmd/dep/testdata/harness_tests/init/glide/trans-trans-trans/final/Gopkg.toml/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/init/glide/trans-trans-trans/final/Gopkg.toml", "repo_id": "dep", "token_count": 39 }
27
{ "commands": [ ["init"] ], "error-expected": "init aborted: manifest already exists", "vendor-final": [] }
dep/cmd/dep/testdata/harness_tests/init/manifest-exists/testcase.json/0
{ "file_path": "dep/cmd/dep/testdata/harness_tests/init/manifest-exists/testcase.json", "repo_id": "dep", "token_count": 45 }
28
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import ( "flag" "runtime" "github.com/golang/dep" ) var ( version = "devel" buildDate string commitHash string ) const versionHelp = `Show the dep version information` func (cmd *versionCommand) Name() string { return "version" } func (cmd *versionCommand) Args() string { return "" } func (cmd *versionCommand) ShortHelp() string { return versionHelp } func (cmd *versionCommand) LongHelp() string { return versionHelp } func (cmd *versionCommand) Hidden() bool { return false } func (cmd *versionCommand) Register(fs *flag.FlagSet) {} type versionCommand struct{} func (cmd *versionCommand) Run(ctx *dep.Ctx, args []string) error { ctx.Out.Printf(`dep: version : %s build date : %s git hash : %s go version : %s go compiler : %s platform : %s/%s features : ImportDuringSolve=%v `, version, buildDate, commitHash, runtime.Version(), runtime.Compiler, runtime.GOOS, runtime.GOARCH, importDuringSolve()) return nil }
dep/cmd/dep/version.go/0
{ "file_path": "dep/cmd/dep/version.go", "repo_id": "dep", "token_count": 377 }
29
--- id: glossary title: Glossary --- dep uses some specialized terminology. Learn about it here! * [Atom](#atom) * [Cache lock](#cache-lock) * [Constraint](#constraint) * [Current Project](#current-project) * [Deducible](#deducible) * [Deduction](#deduction) * [Direct Dependency](#direct-dependency) * [External Import](#external-import) * [GPS](#gps) * [Local cache](#local-cache) * [Lock](#lock) * [Manifest](#manifest) * [Metadata Service](#metadata-service) * [Override](#override) * [Project](#project) * [Project Root](#project-root) * [Solver](#solver) * [Source](#source) * [Source Root](#source-root) * [Sync](#sync) * [Transitive Dependency](#transitive-dependency) * [Vendor Verification](#vendor-verification) --- ### Atom Atoms are a source at a particular version. In practice, this means a two-tuple of [project root](#project-root) and version, e.g. `github.com/foo/bar@master`. Atoms are primarily internal to the [solver](#solver), and the term is rarely used elsewhere. ### Cache lock Also "cache lock file." A file, named `sm.lock`, used to ensure only a single dep process operates on the [local cache](#local-cache) at a time, as it is unsafe in dep's current design for multiple processes to access the local cache. ### Constraint Constraints have both a narrow and a looser meaning. The narrow sense refers to a [`[[constraint]]`](Gopkg.toml.md#constraint) stanza in `Gopkg.toml`. However, in some contexts, the word may be used more loosely to refer to the idea of applying rules and requirements to dependency management in general. ### Current Project The project on which dep is operating - writing its `Gopkg.lock` and populating its `vendor` directory. Also called the "root project." ### Deducible A shorthand way of referring to whether or not import path [deduction](#deduction) will return successfully for a given import path. "Undeducible" is also often used, to refer to an import path for which deduction fails. ### Deduction Deduction is the process of determining the subset of an import path that corresponds to a source root. Some patterns are known a priori (static); others must be discovered via network requests (dynamic). See the reference on [import path deduction](deduction.md) for specifics. ### Direct Dependency A project's direct dependencies are those that it _imports_ from one or more of its packages, or includes in its [`required`](Gopkg.toml.md#required) list in `Gopkg.toml`. If each letter in `A -> B -> C -> D` represents a distinct project containing only a single package, and `->` indicates an import statement, then `B` is `A`'s direct dependency, whereas `C` and `D` are [transitive dependencies](#transitive-dependency) of `A`. Dep only incorporates the `required` rules from the [current project's](#current-project) `Gopkg.toml`. Therefore, if `=>` represents `required` rather than a standard import, and `A -> B => C`, then `C` is a direct dependency of `B` _only_ when `B` is the current project. Because the `B`-to-`C` link does not exist when `A` is the current project, then `C` won't actually be in the graph at all. ### External Import An `import` statement that points to a package in a project other than the one in which it originates. For example, an `import` in package `github.com/foo/bar` will be considered an external import if it points to anything _other_ than stdlib or `github.com/foo/bar/*`. ### GPS Acronym for "Go packaging solver", it is [a subtree of library-style packages within dep](https://godoc.org/github.com/golang/dep/gps), and is the engine around which dep is built. Most commonly referred to as "gps." ### Local cache dep maintains its own, pristine set of upstream sources (so, generally, git repository clones). This is kept separate from `$GOPATH/src` so that there is no obligation to maintain disk state within `$GOPATH`, as dep frequently needs to change disk state in order to do its work. By default, the local cache lives at `$GOPATH/pkg/dep`. If you have multiple `$GOPATH` entries, dep will use whichever is the logical parent of the process' working directory. Alternatively, the location can be forced via the [`DEPCACHEDIR` environment variable](env-vars.md#depcachedir). ### Lock A generic term, used across many language package managers, for the kind of information dep keeps in a `Gopkg.lock` file. ### Manifest A generic term, used across many language package managers, for the kind of information dep keeps in a `Gopkg.toml` file. ### Metadata Service An HTTP service that, when it receives an HTTP request containing a `go-get=1` in the query string, treats interprets the path portion of the request as an import path, and responds by embedding data in HTML `<meta>` tags that indicate the type and URL of of the underlying source root. This is the server-side component of dynamic [deduction](#deduction). The behavior of metadata services is defined in the [Go documentation on remote import paths](https://golang.org/cmd/go/#hdr-Remote_import_paths). Variously referenced as "HTTP metadata service", "`go-get` HTTP metadata service", "`go-get` service", etc. ### Override An override is a [`[[override]]`](Gopkg.toml.md#override) stanza in `Gopkg.toml`. ### Project A project is a tree of Go packages. Projects cannot be nested. See [Project Root](#project-root) for more information about how the root of the tree is determined. ### Project Root The root import path for a project. A project root is defined as: * For the current project, the location of the `Gopkg.toml` file defines the project root * For dependencies, the root of the network [source](#source) (VCS repository) is treated as the project root These are generally one and the same, though not always. When using dep inside a monorepo, multiple `Gopkg.toml` files may exist at subpaths for discrete projects, designating each of those import paths as Project Roots. This works fine when working directly on those projects. If, however, any project not in the repository seeks to import the monorepo, dep will treat the monorepo as one big Project, with the root directory being the Project Root; it will disregard any and all `Gopkg.toml` files in subdirectories. This may also be referred to as the "import root" or "root import path." ### Solver "The solver" is a reference to the domain-specific SAT solver contained in [gps](#gps). More detail can be found on its [reference page](the-solver.md). ### Source The remote entities that hold versioned code. Sources are specifically the entity containing the code, not any particular version of the code itself. "Source" is used in lieu of "VCS" because Go package management tools will soon learn to use more than just VCS systems. ### Source Root The portion of an import path that corresponds to the network location of a source. This is similar to [Project Root](#project-root), but refers strictly to the second, network-oriented definition. ### Sync Dep is designed around a well-defined relationship between four states: 1. `import` statements in `.go` files 2. `Gopkg.toml` 3. `Gopkg.lock` 4. The `vendor` directory If any aspect of the relationship is unfulfilled (e.g., there is an `import` not reflected in `Gopkg.lock`, or a project that's missing from `vendor`), then dep considers the project to be "out of sync." This concept is explored in detail in [ensure mechanics](ensure-mechanics.md#staying-in-sync). ### Transitive Dependency A project's transitive dependencies are those dependencies that it does not import itself, but are imported by one of its dependencies. If each letter in `A -> B -> C -> D` represents a distinct project containing only a single package, and `->` indicates an import statement, then `C` and `D` are `A`'s transitive dependencies, whereas `B` is a [direct dependency](#transitive-dependency) of `A`. ### Vendor Verification Dep guarantees that `vendor/` contains exactly the expected code by hashing the contents of each project and storing the resulting [digest in Gopkg.lock](Gopkg.lock.md#digest). This digest is computed _after_ pruning rules are applied. The digest is used to determine if the contents of `vendor/` need to be regenerated during a `dep ensure` run, and `dep check` uses it to determine whether `Gopkg.lock` and `vendor/` are in [sync](#sync). The [`noverify`](Gopkg.toml.md#noverify) list in `Gopkg.toml` can be used to bypass most of these verification behaviors.
dep/docs/glossary.md/0
{ "file_path": "dep/docs/glossary.md", "repo_id": "dep", "token_count": 2325 }
30
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gps import ( "fmt" "math/rand" "strconv" ) // ProjectRoot is the topmost import path in a tree of other import paths - the // root of the tree. In gps' current design, ProjectRoots have to correspond to // a repository root (mostly), but their real purpose is to identify the root // import path of a "project", logically encompassing all child packages. // // Projects are a crucial unit of operation in gps. Constraints are declared by // a project's manifest, and apply to all packages in a ProjectRoot's tree. // Solving itself mostly proceeds on a project-by-project basis. // // Aliasing string types is usually a bit of an anti-pattern. gps does it here // as a means of clarifying API intent. This is important because Go's package // management domain has lots of different path-ish strings floating around: // // actual directories: // /home/sdboyer/go/src/github.com/sdboyer/gps/example // URLs: // https://github.com/sdboyer/gps // import paths: // github.com/sdboyer/gps/example // portions of import paths that refer to a package: // example // portions that could not possibly refer to anything sane: // github.com/sdboyer // portions that correspond to a repository root: // github.com/sdboyer/gps // // While not a panacea, having ProjectRoot allows gps to clearly indicate via // the type system when a path-ish string must have particular semantics. type ProjectRoot string // A ProjectIdentifier provides the name and source location of a dependency. It // is related to, but differs in two key ways from, a plain import path. // // First, ProjectIdentifiers do not identify a single package. Rather, they // encompass the whole tree of packages, including tree's root - the // ProjectRoot. In gps' current design, this ProjectRoot almost always // corresponds to the root of a repository. // // Second, ProjectIdentifiers can optionally carry a Source, which // identifies where the underlying source code can be located on the network. // These can be either a full URL, including protocol, or plain import paths. // So, these are all valid data for Source: // // github.com/sdboyer/gps // github.com/fork/gps // git@github.com:sdboyer/gps // https://github.com/sdboyer/gps // // With plain import paths, network addresses are derived purely through an // algorithm. By having an explicit network name, it becomes possible to, for // example, transparently substitute a fork for the original upstream source // repository. // // Note that gps makes no guarantees about the actual import paths contained in // a repository aligning with ImportRoot. If tools, or their users, specify an // alternate Source that contains a repository with incompatible internal // import paths, gps' solving operations will error. (gps does no import // rewriting.) // // Also note that if different projects' manifests report a different // Source for a given ImportRoot, it is a solve failure. Everyone has to // agree on where a given import path should be sourced from. // // If Source is not explicitly set, gps will derive the network address from // the ImportRoot using a similar algorithm to that utilized by `go get`. type ProjectIdentifier struct { ProjectRoot ProjectRoot Source string } // Less compares by ProjectRoot then normalized Source. func (i ProjectIdentifier) Less(j ProjectIdentifier) bool { if i.ProjectRoot < j.ProjectRoot { return true } if j.ProjectRoot < i.ProjectRoot { return false } return i.normalizedSource() < j.normalizedSource() } func (i ProjectIdentifier) eq(j ProjectIdentifier) bool { if i.ProjectRoot != j.ProjectRoot { return false } if i.Source == j.Source { return true } if (i.Source == "" && j.Source == string(j.ProjectRoot)) || (j.Source == "" && i.Source == string(i.ProjectRoot)) { return true } return false } // equiv will check if the two identifiers are "equivalent," under special // rules. // // Given that the ProjectRoots are equal (==), equivalency occurs if: // // 1. The Sources are equal (==), OR // 2. The LEFT (the receiver) Source is non-empty, and the right // Source is empty. // // *This is asymmetry in this binary relation is intentional.* It facilitates // the case where we allow for a ProjectIdentifier with an explicit Source // to match one without. func (i ProjectIdentifier) equiv(j ProjectIdentifier) bool { if i.ProjectRoot != j.ProjectRoot { return false } if i.Source == j.Source { return true } if i.Source != "" && j.Source == "" { return true } return false } func (i ProjectIdentifier) normalizedSource() string { if i.Source == "" { return string(i.ProjectRoot) } return i.Source } func (i ProjectIdentifier) String() string { if i.Source == "" || i.Source == string(i.ProjectRoot) { return string(i.ProjectRoot) } return fmt.Sprintf("%s (from %s)", i.ProjectRoot, i.Source) } func (i ProjectIdentifier) normalize() ProjectIdentifier { if i.Source == "" { i.Source = string(i.ProjectRoot) } return i } // ProjectProperties comprise the properties that can be attached to a // ProjectRoot. // // In general, these are declared in the context of a map of ProjectRoot to its // ProjectProperties; they make little sense without their corresponding // ProjectRoot. type ProjectProperties struct { Source string Constraint Constraint } // bimodalIdentifiers are used to track work to be done in the unselected queue. type bimodalIdentifier struct { id ProjectIdentifier // List of packages required within/under the ProjectIdentifier pl []string // prefv is used to indicate a 'preferred' version. This is expected to be // derived from a dep's lock data, or else is empty. prefv Version // Indicates that the bmi came from the root project originally fromRoot bool } type atom struct { id ProjectIdentifier v Version } // With a random revision and no name, collisions are...unlikely var nilpa = atom{ v: Revision(strconv.FormatInt(rand.Int63(), 36)), } type atomWithPackages struct { a atom pl []string } // bmi converts an atomWithPackages into a bimodalIdentifier. // // This is mostly intended for (read-only) trace use, so the package list slice // is not copied. It is the callers responsibility to not modify the pl slice, // lest that backpropagate and cause inconsistencies. func (awp atomWithPackages) bmi() bimodalIdentifier { return bimodalIdentifier{ id: awp.a.id, pl: awp.pl, } } // completeDep (name hopefully to change) provides the whole picture of a // dependency - the root (repo and project, since currently we assume the two // are the same) name, a constraint, and the actual packages needed that are // under that root. type completeDep struct { // The base workingConstraint workingConstraint // The specific packages required from the ProjectDep pl []string } // dependency represents an incomplete edge in the depgraph. It has a // fully-realized atom as the depender (the tail/source of the edge), and a set // of requirements that any atom to be attached at the head/target must satisfy. type dependency struct { depender atom dep completeDep }
dep/gps/identifier.go/0
{ "file_path": "dep/gps/identifier.go", "repo_id": "dep", "token_count": 2059 }
31
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package pkgtree import ( "bytes" "fmt" "go/ast" "go/build" "go/parser" gscan "go/scanner" "go/token" "os" "path/filepath" "sort" "strconv" "strings" "unicode" ) // Package represents a Go package. It contains a subset of the information // go/build.Package does. type Package struct { Name string // Package name, as declared in the package statement ImportPath string // Full import path, including the prefix provided to ListPackages() CommentPath string // Import path given in the comment on the package statement Imports []string // Imports from all go and cgo files TestImports []string // Imports from all go test files (in go/build parlance: both TestImports and XTestImports) } // vcsRoots is a set of directories we should not descend into in ListPackages when // searching for Go packages var vcsRoots = map[string]struct{}{ ".git": {}, ".bzr": {}, ".svn": {}, ".hg": {}, } // ListPackages reports Go package information about all directories in the tree // at or below the provided fileRoot. // // The importRoot parameter is prepended to the relative path when determining // the import path for each package. The obvious case is for something typical, // like: // // fileRoot = "/home/user/go/src/github.com/foo/bar" // importRoot = "github.com/foo/bar" // // where the fileRoot and importRoot align. However, if you provide: // // fileRoot = "/home/user/workspace/path/to/repo" // importRoot = "github.com/foo/bar" // // then the root package at path/to/repo will be ascribed import path // "github.com/foo/bar", and the package at // "/home/user/workspace/path/to/repo/baz" will be "github.com/foo/bar/baz". // // A PackageTree is returned, which contains the ImportRoot and map of import path // to PackageOrErr - each path under the root that exists will have either a // Package, or an error describing why the directory is not a valid package. func ListPackages(fileRoot, importRoot string) (PackageTree, error) { ptree := PackageTree{ ImportRoot: importRoot, Packages: make(map[string]PackageOrErr), } var err error fileRoot, err = filepath.Abs(fileRoot) if err != nil { return PackageTree{}, err } err = filepath.Walk(fileRoot, func(wp string, fi os.FileInfo, err error) error { if err != nil && err != filepath.SkipDir { if os.IsPermission(err) { return filepath.SkipDir } return err } if !fi.IsDir() { return nil } // Skip dirs that are known to hold non-local/dependency code. // // We don't skip _*, or testdata dirs because, while it may be poor // form, importing them is not a compilation error. switch fi.Name() { case "vendor": return filepath.SkipDir } // Skip dirs that are known to be VCS roots. // // Note that there are some pathological edge cases this doesn't cover, // such as a user using Git for version control, but having a package // named "svn" in a directory named ".svn". if _, ok := vcsRoots[fi.Name()]; ok { return filepath.SkipDir } { // For Go 1.9 and earlier: // // The entry error is nil when visiting a directory that itself is // untraversable, as it's still governed by the parent directory's // perms. We have to check readability of the dir here, because // otherwise we'll have an empty package entry when we fail to read any // of the dir's contents. // // If we didn't check here, then the next time this closure is called it // would have an err with the same path as is called this time, as only // then will filepath.Walk have attempted to descend into the directory // and encountered an error. var f *os.File f, err = os.Open(wp) if err != nil { if os.IsPermission(err) { return filepath.SkipDir } return err } f.Close() } // Compute the import path. Run the result through ToSlash(), so that // windows file paths are normalized to slashes, as is expected of // import paths. ip := filepath.ToSlash(filepath.Join(importRoot, strings.TrimPrefix(wp, fileRoot))) // Find all the imports, across all os/arch combos p := &build.Package{ Dir: wp, ImportPath: ip, } err = fillPackage(p) if err != nil { switch err.(type) { case gscan.ErrorList, *gscan.Error, *build.NoGoError, *ConflictingImportComments: // Assorted cases in which we've encountered malformed or // nonexistent Go source code. ptree.Packages[ip] = PackageOrErr{ Err: err, } return nil default: return err } } pkg := Package{ ImportPath: ip, CommentPath: p.ImportComment, Name: p.Name, Imports: p.Imports, TestImports: dedupeStrings(p.TestImports, p.XTestImports), } if pkg.CommentPath != "" && !strings.HasPrefix(pkg.CommentPath, importRoot) { ptree.Packages[ip] = PackageOrErr{ Err: &NonCanonicalImportRoot{ ImportRoot: importRoot, Canonical: pkg.CommentPath, }, } return nil } // This area has some...fuzzy rules, but check all the imports for // local/relative/dot-ness, and record an error for the package if we // see any. var lim []string for _, imp := range append(pkg.Imports, pkg.TestImports...) { if build.IsLocalImport(imp) { // Do allow the single-dot, at least for now if imp == "." { continue } lim = append(lim, imp) } } if len(lim) > 0 { ptree.Packages[ip] = PackageOrErr{ Err: &LocalImportsError{ Dir: wp, ImportPath: ip, LocalImports: lim, }, } } else { ptree.Packages[ip] = PackageOrErr{ P: pkg, } } return nil }) if err != nil { return PackageTree{}, err } return ptree, nil } // fillPackage full of info. Assumes p.Dir is set at a minimum func fillPackage(p *build.Package) error { var buildPrefix = "// +build " var buildFieldSplit = func(r rune) bool { return unicode.IsSpace(r) || r == ',' } gofiles, err := filepath.Glob(filepath.Join(p.Dir, "*.go")) if err != nil { return err } if len(gofiles) == 0 { return &build.NoGoError{Dir: p.Dir} } var testImports []string var imports []string var importComments []string for _, file := range gofiles { // Skip underscore-led or dot-led files, in keeping with the rest of the toolchain. bPrefix := filepath.Base(file)[0] if bPrefix == '_' || bPrefix == '.' { continue } // Skip any directories that happened to get caught by glob if stat, err := os.Stat(file); err == nil && stat.IsDir() { continue } pf, err := parser.ParseFile(token.NewFileSet(), file, nil, parser.ImportsOnly|parser.ParseComments) if err != nil { if os.IsPermission(err) { continue } return err } testFile := strings.HasSuffix(file, "_test.go") fname := filepath.Base(file) var ignored bool for _, c := range pf.Comments { ic := findImportComment(pf.Name, c) if ic != "" { importComments = append(importComments, ic) } if c.Pos() > pf.Package { // "+build" comment must come before package continue } var ct string for _, cl := range c.List { if strings.HasPrefix(cl.Text, buildPrefix) { ct = cl.Text break } } if ct == "" { continue } for _, t := range strings.FieldsFunc(ct[len(buildPrefix):], buildFieldSplit) { // hardcoded (for now) handling for the "ignore" build tag // We "soft" ignore the files tagged with ignore so that we pull in their imports. if t == "ignore" { ignored = true } } } if testFile { p.TestGoFiles = append(p.TestGoFiles, fname) if p.Name == "" && !ignored { p.Name = strings.TrimSuffix(pf.Name.Name, "_test") } } else { if p.Name == "" && !ignored { p.Name = pf.Name.Name } p.GoFiles = append(p.GoFiles, fname) } for _, is := range pf.Imports { name, err := strconv.Unquote(is.Path.Value) if err != nil { return err // can't happen? } if testFile { testImports = append(testImports, name) } else { imports = append(imports, name) } } } importComments = uniq(importComments) if len(importComments) > 1 { return &ConflictingImportComments{ ImportPath: p.ImportPath, ConflictingImportComments: importComments, } } if len(importComments) > 0 { p.ImportComment = importComments[0] } imports = uniq(imports) testImports = uniq(testImports) p.Imports = imports p.TestImports = testImports return nil } var ( slashSlash = []byte("//") slashStar = []byte("/*") starSlash = []byte("*/") importKwd = []byte("import ") ) func findImportComment(pkgName *ast.Ident, c *ast.CommentGroup) string { afterPkg := pkgName.NamePos + token.Pos(len(pkgName.Name)) + 1 commentSlash := c.List[0].Slash if afterPkg != commentSlash { return "" } text := []byte(c.List[0].Text) switch { case bytes.HasPrefix(text, slashSlash): eol := bytes.IndexByte(text, '\n') if eol < 0 { eol = len(text) } text = text[2:eol] case bytes.HasPrefix(text, slashStar): text = text[2:] end := bytes.Index(text, starSlash) if end < 0 { // malformed comment return "" } text = text[:end] if bytes.IndexByte(text, '\n') >= 0 { // multiline comment, can't be an import comment return "" } } text = bytes.TrimSpace(text) if !bytes.HasPrefix(text, importKwd) { return "" } quotedPath := bytes.TrimSpace(text[len(importKwd):]) return string(bytes.Trim(quotedPath, `"`)) } // ConflictingImportComments indicates that the package declares more than one // different canonical path. type ConflictingImportComments struct { ImportPath string // An import path referring to this package ConflictingImportComments []string // All distinct "canonical" paths encountered in the package files } func (e *ConflictingImportComments) Error() string { return fmt.Sprintf("import path %s had conflicting import comments: %s", e.ImportPath, quotedPaths(e.ConflictingImportComments)) } // NonCanonicalImportRoot reports the situation when the dependee imports a // package via something other than the package's declared canonical path. type NonCanonicalImportRoot struct { ImportRoot string // A root path that is being used to import a package Canonical string // A canonical path declared by the package being imported } func (e *NonCanonicalImportRoot) Error() string { return fmt.Sprintf("import root %q is not a prefix for the package's declared canonical path %q", e.ImportRoot, e.Canonical) } func quotedPaths(ps []string) string { quoted := make([]string, 0, len(ps)) for _, p := range ps { quoted = append(quoted, fmt.Sprintf("%q", p)) } return strings.Join(quoted, ", ") } // LocalImportsError indicates that a package contains at least one relative // import that will prevent it from compiling. // // TODO(sdboyer) add a Files property once we're doing our own per-file parsing type LocalImportsError struct { ImportPath string Dir string LocalImports []string } func (e *LocalImportsError) Error() string { switch len(e.LocalImports) { case 0: // shouldn't be possible, but just cover the case return fmt.Sprintf("import path %s had bad local imports", e.ImportPath) case 1: return fmt.Sprintf("import path %s had a local import: %q", e.ImportPath, e.LocalImports[0]) default: return fmt.Sprintf("import path %s had local imports: %s", e.ImportPath, quotedPaths(e.LocalImports)) } } type wm struct { err error ex map[string]bool in map[string]bool } // PackageOrErr stores the results of attempting to parse a single directory for // Go source code. type PackageOrErr struct { P Package Err error } // ProblemImportError describes the reason that a particular import path is // not safely importable. type ProblemImportError struct { // The import path of the package with some problem rendering it // unimportable. ImportPath string // The path to the internal package the problem package imports that is the // original cause of this issue. If empty, the package itself is the // problem. Cause []string // The actual error from ListPackages that is undermining importability for // this package. Err error } // Error formats the ProblemImportError as a string, reflecting whether the // error represents a direct or transitive problem. func (e *ProblemImportError) Error() string { switch len(e.Cause) { case 0: return fmt.Sprintf("%q contains malformed code: %s", e.ImportPath, e.Err.Error()) case 1: return fmt.Sprintf("%q imports %q, which contains malformed code: %s", e.ImportPath, e.Cause[0], e.Err.Error()) default: return fmt.Sprintf("%q transitively (through %v packages) imports %q, which contains malformed code: %s", e.ImportPath, len(e.Cause)-1, e.Cause[len(e.Cause)-1], e.Err.Error()) } } // Helper func to create an error when a package is missing. func missingPkgErr(pkg string) error { return fmt.Errorf("no package exists at %q", pkg) } // A PackageTree represents the results of recursively parsing a tree of // packages, starting at the ImportRoot. The results of parsing the files in the // directory identified by each import path - a Package or an error - are stored // in the Packages map, keyed by that import path. type PackageTree struct { ImportRoot string Packages map[string]PackageOrErr } // ToReachMap looks through a PackageTree and computes the list of external // import statements (that is, import statements pointing to packages that are // not logical children of PackageTree.ImportRoot) that are transitively // imported by the internal packages in the tree. // // main indicates whether (true) or not (false) to include main packages in the // analysis. When utilized by gps' solver, main packages are generally excluded // from analyzing anything other than the root project, as they necessarily can't // be imported. // // tests indicates whether (true) or not (false) to include imports from test // files in packages when computing the reach map. // // backprop indicates whether errors (an actual PackageOrErr.Err, or an import // to a nonexistent internal package) should be backpropagated, transitively // "poisoning" all corresponding importers to all importers. // // ignore is a map of import paths that, if encountered, should be excluded from // analysis. This exclusion applies to both internal and external packages. If // an external import path is ignored, it is simply omitted from the results. // // If an internal path is ignored, then it not only does not appear in the final // map, but it is also excluded from the transitive calculations of other // internal packages. That is, if you ignore A/foo, then the external package // list for all internal packages that import A/foo will not include external // packages that are only reachable through A/foo. // // Visually, this means that, given a PackageTree with root A and packages at A, // A/foo, and A/bar, and the following import chain: // // A -> A/foo -> A/bar -> B/baz // // In this configuration, all of A's packages transitively import B/baz, so the // returned map would be: // // map[string][]string{ // "A": []string{"B/baz"}, // "A/foo": []string{"B/baz"} // "A/bar": []string{"B/baz"}, // } // // However, if you ignore A/foo, then A's path to B/baz is broken, and A/foo is // omitted entirely. Thus, the returned map would be: // // map[string][]string{ // "A": []string{}, // "A/bar": []string{"B/baz"}, // } // // If there are no packages to ignore, it is safe to pass a nil map. // // Finally, if an internal PackageOrErr contains an error, it is always omitted // from the result set. If backprop is true, then the error from that internal // package will be transitively propagated back to any other internal // PackageOrErrs that import it, causing them to also be omitted. So, with the // same import chain: // // A -> A/foo -> A/bar -> B/baz // // If A/foo has an error, then it would backpropagate to A, causing both to be // omitted, and the returned map to contain only A/bar: // // map[string][]string{ // "A/bar": []string{"B/baz"}, // } // // If backprop is false, then errors will not backpropagate to internal // importers. So, with an error in A/foo, this would be the result map: // // map[string][]string{ // "A": []string{}, // "A/bar": []string{"B/baz"}, // } func (t PackageTree) ToReachMap(main, tests, backprop bool, ignore *IgnoredRuleset) (ReachMap, map[string]*ProblemImportError) { // world's simplest adjacency list workmap := make(map[string]wm) var imps []string for ip, perr := range t.Packages { if perr.Err != nil { workmap[ip] = wm{ err: perr.Err, } continue } p := perr.P // Skip main packages, unless param says otherwise if p.Name == "main" && !main { continue } // Skip ignored packages if ignore.IsIgnored(ip) { continue } // TODO (kris-nova) Disable to get staticcheck passing //imps = imps[:0] if tests { imps = dedupeStrings(p.Imports, p.TestImports) } else { imps = p.Imports } w := wm{ ex: make(map[string]bool), in: make(map[string]bool), } // For each import, decide whether it should be ignored, or if it // belongs in the external or internal imports list. for _, imp := range imps { if ignore.IsIgnored(imp) || imp == "." { continue } if !eqOrSlashedPrefix(imp, t.ImportRoot) { w.ex[imp] = true } else { w.in[imp] = true } } workmap[ip] = w } return wmToReach(workmap, backprop) } // Copy copies the PackageTree. // // This is really only useful as a defensive measure to prevent external state // mutations. func (t PackageTree) Copy() PackageTree { return PackageTree{ ImportRoot: t.ImportRoot, Packages: CopyPackages(t.Packages, nil), } } // CopyPackages returns a deep copy of p, optionally modifying the entries with fn. func CopyPackages(p map[string]PackageOrErr, fn func(string, PackageOrErr) (string, PackageOrErr)) map[string]PackageOrErr { p2 := make(map[string]PackageOrErr, len(p)) // Walk through and count up the total number of string slice elements we'll // need, then allocate them all at once. strcount := 0 for _, poe := range p { strcount = strcount + len(poe.P.Imports) + len(poe.P.TestImports) } pool := make([]string, strcount) for path, poe := range p { var poe2 PackageOrErr if poe.Err != nil { poe2.Err = poe.Err } else { poe2.P = poe.P il, til := len(poe.P.Imports), len(poe.P.TestImports) if il > 0 { poe2.P.Imports, pool = pool[:il], pool[il:] copy(poe2.P.Imports, poe.P.Imports) } if til > 0 { poe2.P.TestImports, pool = pool[:til], pool[til:] copy(poe2.P.TestImports, poe.P.TestImports) } } if fn != nil { path, poe2 = fn(path, poe2) } p2[path] = poe2 } return p2 } // TrimHiddenPackages returns a new PackageTree where packages that are ignored, // or both hidden and unreachable, have been removed. // // The package list is partitioned into two sets: visible, and hidden, where // packages are considered hidden if they are within or beneath directories // with: // // * leading dots // * leading underscores // * the exact name "testdata" // // Packages in the hidden set are dropped from the returned PackageTree, unless // they are transitively reachable from imports in the visible set. // // The "main", "tests" and "ignored" parameters have the same behavior as with // PackageTree.ToReachMap(): the first two determine, respectively, whether // imports from main packages, and imports from tests, should be considered for // reachability checks. Setting 'main' to true will additionally result in main // packages being trimmed. // // "ignored" designates import paths, or patterns of import paths, where the // corresponding packages should be excluded from reachability checks, if // encountered. Ignored packages are also removed from the final set. // // Note that it is not recommended to call this method if the goal is to obtain // a set of tree-external imports; calling ToReachMap and FlattenFn will achieve // the same effect. func (t PackageTree) TrimHiddenPackages(main, tests bool, ignore *IgnoredRuleset) PackageTree { rm, pie := t.ToReachMap(main, tests, false, ignore) t2 := t.Copy() preserve := make(map[string]bool) for pkg, ie := range rm { if pkgFilter(pkg) && !ignore.IsIgnored(pkg) { preserve[pkg] = true for _, in := range ie.Internal { preserve[in] = true } } } // Also process the problem map, as packages in the visible set with errors // need to be included in the return values. for pkg := range pie { if pkgFilter(pkg) && !ignore.IsIgnored(pkg) { preserve[pkg] = true } } for ip := range t.Packages { if !preserve[ip] { delete(t2.Packages, ip) } } return t2 } // wmToReach takes an internal "workmap" constructed by // PackageTree.ExternalReach(), transitively walks (via depth-first traversal) // all internal imports until they reach an external path or terminate, then // translates the results into a slice of external imports for each internal // pkg. // // It drops any packages with errors, and - if backprop is true - backpropagates // those errors, causing internal packages that (transitively) import other // internal packages having errors to also be dropped. func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*ProblemImportError) { // Uses depth-first exploration to compute reachability into external // packages, dropping any internal packages on "poisoned paths" - a path // containing a package with an error, or with a dep on an internal package // that's missing. const ( white uint8 = iota grey black ) colors := make(map[string]uint8) exrsets := make(map[string]map[string]struct{}) inrsets := make(map[string]map[string]struct{}) errmap := make(map[string]*ProblemImportError) // poison is a helper func to eliminate specific reachsets from exrsets and // inrsets, and populate error information along the way. poison := func(path []string, err *ProblemImportError) { for k, ppkg := range path { delete(exrsets, ppkg) delete(inrsets, ppkg) // Duplicate the err for this package kerr := &ProblemImportError{ ImportPath: ppkg, Err: err.Err, } // Shift the slice bounds on the incoming err.Cause. // // This check will only be false on the final path element when // entering via poisonWhite, where the last pkg is the underlying // cause of the problem, and is thus expected to have an empty Cause // slice. if k+1 < len(err.Cause) { // reuse the slice kerr.Cause = err.Cause[k+1:] } // Both black and white cases can have the final element be a // package that doesn't exist. If that's the case, don't write it // directly to the errmap, as presence in the errmap indicates the // package was present in the input PackageTree. if k == len(path)-1 { if _, exists := workmap[path[len(path)-1]]; !exists { continue } } // Direct writing to the errmap means that if multiple errors affect // a given package, only the last error visited will be reported. // But that should be sufficient; presumably, the user can // iteratively resolve the errors. errmap[ppkg] = kerr } } // poisonWhite wraps poison for error recording in the white-poisoning case, // where we're constructing a new poison path. poisonWhite := func(path []string) { err := &ProblemImportError{ Cause: make([]string, len(path)), } copy(err.Cause, path) // find the tail err tail := path[len(path)-1] if w, exists := workmap[tail]; exists { // If we make it to here, the dfe guarantees that the workmap // will contain an error for this pkg. err.Err = w.err } else { err.Err = missingPkgErr(tail) } poison(path, err) } // poisonBlack wraps poison for error recording in the black-poisoning case, // where we're connecting to an existing poison path. poisonBlack := func(path []string, from string) { // Because the outer dfe loop ensures we never directly re-visit a pkg // that was already completed (black), we don't have to defend against // an empty path here. fromErr, exists := errmap[from] // FIXME: It should not be possible for fromErr to not exist, // See issue https://github.com/golang/dep/issues/351 // This is a temporary solution to avoid a panic. if !exists { fromErr = &ProblemImportError{ Err: fmt.Errorf("unknown error for %q, if you get this error see https://github.com/golang/dep/issues/351", from), } } err := &ProblemImportError{ Err: fromErr.Err, Cause: make([]string, 0, len(path)+len(fromErr.Cause)+1), } err.Cause = append(err.Cause, path...) err.Cause = append(err.Cause, from) err.Cause = append(err.Cause, fromErr.Cause...) poison(path, err) } var dfe func(string, []string) bool // dfe is the depth-first-explorer that computes a safe, error-free external // reach map. // // pkg is the import path of the pkg currently being visited; path is the // stack of parent packages we've visited to get to pkg. The return value // indicates whether the level completed successfully (true) or if it was // poisoned (false). dfe = func(pkg string, path []string) bool { // white is the zero value of uint8, which is what we want if the pkg // isn't in the colors map, so this works fine switch colors[pkg] { case white: // first visit to this pkg; mark it as in-process (grey) colors[pkg] = grey // make sure it's present and w/out errs w, exists := workmap[pkg] // Push current visitee onto the path slice. Passing path through // recursion levels as a value has the effect of auto-popping the // slice, while also giving us safe memory reuse. path = append(path, pkg) if !exists || w.err != nil { if backprop { // Does not exist or has an err; poison self and all parents poisonWhite(path) } else if exists { // Only record something in the errmap if there's actually a // package there, per the semantics of the errmap errmap[pkg] = &ProblemImportError{ ImportPath: pkg, Err: w.err, } } // we know we're done here, so mark it black colors[pkg] = black return false } // pkg exists with no errs; start internal and external reachsets for it. rs := make(map[string]struct{}) irs := make(map[string]struct{}) // Dump this package's external pkgs into its own reachset. Separate // loop from the parent dump to avoid nested map loop lookups. for ex := range w.ex { rs[ex] = struct{}{} } exrsets[pkg] = rs // Same deal for internal imports for in := range w.in { irs[in] = struct{}{} } inrsets[pkg] = irs // Push this pkg's imports into all parent reachsets. Not all // parents will necessarily have a reachset; none, some, or all // could have been poisoned by a different path than what we're on // right now. for _, ppkg := range path { if prs, exists := exrsets[ppkg]; exists { for ex := range w.ex { prs[ex] = struct{}{} } } if prs, exists := inrsets[ppkg]; exists { for in := range w.in { prs[in] = struct{}{} } } } // Now, recurse until done, or a false bubbles up, indicating the // path is poisoned. for in := range w.in { clean := dfe(in, path) if !clean && backprop { // Path is poisoned. If we're backpropagating errors, then // the reachmap for the visitee was already deleted by the // path we're returning from; mark the visitee black, then // return false to bubble up the poison. This is OK to do // early, before exploring all internal imports, because the // outer loop visits all internal packages anyway. // // In fact, stopping early is preferable - white subpackages // won't have to iterate pointlessly through a parent path // with no reachset. colors[pkg] = black return false } } // Fully done with this pkg; no transitive problems. colors[pkg] = black return true case grey: // Grey means an import cycle. These can arise in healthy situations // through xtest. They can also arise in less healthy but valid // situations where an edge in the import graph is reversed based on // the presence of a build tag. For example, if A depends on B on // Linux, but B depends on A on Darwin, the import graph is not // cyclic on either Linux or Darwin but dep will see what appears to // be a dependency cycle because it considers all tags at once. // // Handling import cycles for the purposes of reachablity is // straightforward: we treat all packages in the cycle as // equivalent. Any package imported by one package in the cycle is // necessarily reachable by all other packages in the cycle. // Merge the reachsets in the cycle by sharing the same external // reachset and internal reachset amongst all packages in the // cycle. var cycleStarted bool for _, ppkg := range path { if cycleStarted { exrsets[ppkg] = exrsets[pkg] inrsets[ppkg] = inrsets[pkg] } else if ppkg == pkg { cycleStarted = true } } if !cycleStarted { panic(fmt.Sprintf("path to grey package %s did not include cycle: %s", pkg, path)) } return true case black: // black means we're revisiting a package that was already // completely explored. If it has an entry in exrsets, it completed // successfully. If not, it was poisoned, and we need to bubble the // poison back up. rs, exists := exrsets[pkg] if !exists { if backprop { // just poison parents; self was necessarily already poisoned poisonBlack(path, pkg) } return false } // If external reachset existed, internal must (even if empty) irs := inrsets[pkg] // It's good; pull over the imports from its reachset into all // non-poisoned parent reachsets for _, ppkg := range path { if prs, exists := exrsets[ppkg]; exists { for ex := range rs { prs[ex] = struct{}{} } } if prs, exists := inrsets[ppkg]; exists { for in := range irs { prs[in] = struct{}{} } } } return true default: panic(fmt.Sprintf("invalid color marker %v for %s", colors[pkg], pkg)) } } // Run the depth-first exploration. // // Don't bother computing graph sources, this straightforward loop works // comparably well, and fits nicely with an escape hatch in the dfe. var path []string for pkg := range workmap { // However, at least check that the package isn't already fully visited; // this saves a bit of time and implementation complexity inside the // closures. if colors[pkg] != black { dfe(pkg, path) } } type ie struct { Internal, External []string } // Flatten exrsets into reachmap rm := make(ReachMap) for pkg, rs := range exrsets { rlen := len(rs) if rlen == 0 { rm[pkg] = ie{} continue } edeps := make([]string, 0, rlen) for opkg := range rs { edeps = append(edeps, opkg) } sort.Strings(edeps) sets := rm[pkg] sets.External = edeps rm[pkg] = sets } // Flatten inrsets into reachmap for pkg, rs := range inrsets { rlen := len(rs) if rlen == 0 { continue } ideps := make([]string, 0, rlen) for opkg := range rs { ideps = append(ideps, opkg) } sort.Strings(ideps) sets := rm[pkg] sets.Internal = ideps rm[pkg] = sets } return rm, errmap } // eqOrSlashedPrefix checks to see if the prefix is either equal to the string, // or that it is a prefix and the next char in the string is "/". func eqOrSlashedPrefix(s, prefix string) bool { if !strings.HasPrefix(s, prefix) { return false } prflen, pathlen := len(prefix), len(s) return prflen == pathlen || strings.Index(s[prflen:], "/") == 0 } // helper func to merge, dedupe, and sort strings func dedupeStrings(s1, s2 []string) (r []string) { dedupe := make(map[string]bool) if len(s1) > 0 && len(s2) > 0 { for _, i := range s1 { dedupe[i] = true } for _, i := range s2 { dedupe[i] = true } for i := range dedupe { r = append(r, i) } // And then re-sort them sort.Strings(r) } else if len(s1) > 0 { r = s1 } else if len(s2) > 0 { r = s2 } return } func uniq(a []string) []string { if a == nil { return make([]string, 0) } var s string var i int if !sort.StringsAreSorted(a) { sort.Strings(a) } for _, t := range a { if t != s { a[i] = t i++ s = t } } return a[:i] }
dep/gps/pkgtree/pkgtree.go/0
{ "file_path": "dep/gps/pkgtree/pkgtree.go", "repo_id": "dep", "token_count": 11647 }
32
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gps import ( "container/heap" "context" "fmt" "log" "sort" "strings" "sync" "sync/atomic" "github.com/armon/go-radix" "github.com/golang/dep/gps/paths" "github.com/golang/dep/gps/pkgtree" "github.com/pkg/errors" ) var rootRev = Revision("") // SolveParameters hold all arguments to a solver run. // // Only RootDir and RootPackageTree are absolutely required. A nil Manifest is // allowed, though it usually makes little sense. // // Of these properties, only the Manifest and RootPackageTree are (directly) // incorporated in memoization hashing. type SolveParameters struct { // The path to the root of the project on which the solver should operate. // This should point to the directory that should contain the vendor/ // directory. // // In general, it is wise for this to be under an active GOPATH, though it // is not (currently) required. // // A real path to a readable directory is required. RootDir string // The ProjectAnalyzer is responsible for extracting Manifest and // (optionally) Lock information from dependencies. The solver passes it // along to its SourceManager's GetManifestAndLock() method as needed. // // An analyzer is required. ProjectAnalyzer ProjectAnalyzer // The tree of packages that comprise the root project, as well as the // import path that should identify the root of that tree. // // In most situations, tools should simply pass the result of ListPackages() // directly through here. // // The ImportRoot property must be a non-empty string, and at least one // element must be present in the Packages map. RootPackageTree pkgtree.PackageTree // The root manifest. This contains all the dependency constraints // associated with normal Manifests, as well as the particular controls // afforded only to the root project. // // May be nil, but for most cases, that would be unwise. Manifest RootManifest // The root lock. Optional. Generally, this lock is the output of a previous // solve run. // // If provided, the solver will attempt to preserve the versions specified // in the lock, unless ToChange or ChangeAll settings indicate otherwise. Lock Lock // ToChange is a list of project names that should be changed - that is, any // versions specified for those projects in the root lock file should be // ignored. // // Passing ChangeAll has subtly different behavior from enumerating all // projects into ToChange. In general, ToChange should *only* be used if the // user expressly requested an upgrade for a specific project. ToChange []ProjectRoot // ChangeAll indicates that all projects should be changed - that is, any // versions specified in the root lock file should be ignored. ChangeAll bool // Downgrade indicates whether the solver will attempt to upgrade (false) or // downgrade (true) projects that are not locked, or are marked for change. // // Upgrading is, by far, the most typical case. The field is named // 'Downgrade' so that the bool's zero value corresponds to that most // typical case. Downgrade bool // TraceLogger is the logger to use for generating trace output. If set, the // solver will generate informative trace output as it moves through the // solving process. TraceLogger *log.Logger // stdLibFn is the function to use to recognize standard library import paths. // Only overridden for tests. Defaults to paths.IsStandardImportPath if nil. stdLibFn func(string) bool // mkBridgeFn is the function to use to create sourceBridges. // Only overridden for tests (so we can run with virtual RootDir). // Defaults to mkBridge if nil. mkBridgeFn func(*solver, SourceManager, bool) sourceBridge } // solver is a CDCL-style constraint solver with satisfiability conditions // hardcoded to the needs of the Go package management problem space. type solver struct { // The current number of attempts made over the course of this solve. This // number increments each time the algorithm completes a backtrack and // starts moving forward again. attempts int // Logger used exclusively for trace output, or nil to suppress. tl *log.Logger // The function to use to recognize standard library import paths. stdLibFn func(string) bool // A bridge to the standard SourceManager. The adapter does some local // caching of pre-sorted version lists, as well as translation between the // full-on ProjectIdentifiers that the solver deals with and the simplified // names a SourceManager operates on. b sourceBridge // A stack containing projects and packages that are currently "selected" - // that is, they have passed all satisfiability checks, and are part of the // current solution. // // The *selection type is mostly just a dumb data container; the solver // itself is responsible for maintaining that invariant. sel *selection // The current list of projects that we need to incorporate into the solution in // order for the solution to be complete. This list is implemented as a // priority queue that places projects least likely to induce errors at the // front, in order to minimize the amount of backtracking required to find a // solution. // // Entries are added to and removed from this list by the solver at the same // time that the selected queue is updated, either with an addition or // removal. unsel *unselected // A stack of all the currently active versionQueues in the solver. The set // of projects represented here corresponds closely to what's in s.sel, // although s.sel will always contain the root project, and s.vqs never // will. Also, s.vqs is only added to (or popped from during backtracking) // when a new project is selected; it is untouched when new packages are // added to an existing project. vqs []*versionQueue // Contains data and constraining information from the root project rd rootdata // metrics for the current solve run. mtr *metrics // Indicates whether the solver has been run. It is invalid to run this type // of solver more than once. hasrun int32 } func (params SolveParameters) toRootdata() (rootdata, error) { if params.ProjectAnalyzer == nil { return rootdata{}, badOptsFailure("must provide a ProjectAnalyzer") } if params.RootDir == "" { return rootdata{}, badOptsFailure("params must specify a non-empty root directory") } if params.RootPackageTree.ImportRoot == "" { return rootdata{}, badOptsFailure("params must include a non-empty import root") } if len(params.RootPackageTree.Packages) == 0 { return rootdata{}, badOptsFailure("at least one package must be present in the PackageTree") } if params.Lock == nil && len(params.ToChange) != 0 { return rootdata{}, badOptsFailure(fmt.Sprintf("update specifically requested for %s, but no lock was provided to upgrade from", params.ToChange)) } if params.Manifest == nil { params.Manifest = simpleRootManifest{} } rd := rootdata{ ir: params.Manifest.IgnoredPackages(), req: params.Manifest.RequiredPackages(), ovr: params.Manifest.Overrides(), rpt: params.RootPackageTree.Copy(), chng: make(map[ProjectRoot]struct{}), rlm: make(map[ProjectRoot]LockedProject), chngall: params.ChangeAll, dir: params.RootDir, an: params.ProjectAnalyzer, } // Ensure the required and overrides maps are at least initialized if rd.req == nil { rd.req = make(map[string]bool) } if rd.ovr == nil { rd.ovr = make(ProjectConstraints) } if rd.ir.Len() > 0 { var both []string for pkg := range params.Manifest.RequiredPackages() { if rd.ir.IsIgnored(pkg) { both = append(both, pkg) } } switch len(both) { case 0: break case 1: return rootdata{}, badOptsFailure(fmt.Sprintf("%q was given as both a required and ignored package", both[0])) default: return rootdata{}, badOptsFailure(fmt.Sprintf("multiple packages given as both required and ignored: %s", strings.Join(both, ", "))) } } // Validate no empties in the overrides map var eovr []string for pr, pp := range rd.ovr { if pp.Constraint == nil && pp.Source == "" { eovr = append(eovr, string(pr)) } } if eovr != nil { // Maybe it's a little nitpicky to do this (we COULD proceed; empty // overrides have no effect), but this errs on the side of letting the // tool/user know there's bad input. Purely as a principle, that seems // preferable to silently allowing progress with icky input. if len(eovr) > 1 { return rootdata{}, badOptsFailure(fmt.Sprintf("Overrides lacked any non-zero properties for multiple project roots: %s", strings.Join(eovr, " "))) } return rootdata{}, badOptsFailure(fmt.Sprintf("An override was declared for %s, but without any non-zero properties", eovr[0])) } // Prep safe, normalized versions of root manifest and lock data rd.rm = prepManifest(params.Manifest) if params.Lock != nil { for _, lp := range params.Lock.Projects() { rd.rlm[lp.Ident().ProjectRoot] = lp } // Also keep a prepped one, mostly for the bridge. This is probably // wasteful, but only minimally so, and yay symmetry rd.rl = prepLock(params.Lock) } for _, p := range params.ToChange { if _, exists := rd.rlm[p]; !exists { return rootdata{}, badOptsFailure(fmt.Sprintf("cannot update %s as it is not in the lock", p)) } rd.chng[p] = struct{}{} } return rd, nil } // Prepare readies a Solver for use. // // This function reads and validates the provided SolveParameters. If a problem // with the inputs is detected, an error is returned. Otherwise, a Solver is // returned, ready to hash and check inputs or perform a solving run. func Prepare(params SolveParameters, sm SourceManager) (Solver, error) { if sm == nil { return nil, badOptsFailure("must provide non-nil SourceManager") } rd, err := params.toRootdata() if err != nil { return nil, err } if params.stdLibFn == nil { params.stdLibFn = paths.IsStandardImportPath } s := &solver{ tl: params.TraceLogger, stdLibFn: params.stdLibFn, rd: rd, } // Set up the bridge and ensure the root dir is in good, working order // before doing anything else. if params.mkBridgeFn == nil { s.b = mkBridge(s, sm, params.Downgrade) } else { s.b = params.mkBridgeFn(s, sm, params.Downgrade) } err = s.b.verifyRootDir(params.RootDir) if err != nil { return nil, err } // Initialize stacks and queues s.sel = &selection{ deps: make(map[ProjectRoot][]dependency), foldRoots: make(map[string]ProjectRoot), } s.unsel = &unselected{ sl: make([]bimodalIdentifier, 0), cmp: s.unselectedComparator, } return s, nil } // A Solver is the main workhorse of gps: given a set of project inputs, it // performs a constraint solving analysis to develop a complete Solution, or // else fail with an informative error. // // If a Solution is found, an implementing tool may persist it - typically into // a "lock file" - and/or use it to write out a directory tree of dependencies, // suitable to be a vendor directory, via CreateVendorTree. type Solver interface { // Solve initiates a solving run. It will either abort due to a canceled // Context, complete successfully with a Solution, or fail with an // informative error. // // It is generally not allowed that this method be called twice for any // given solver. Solve(context.Context) (Solution, error) // Name returns a string identifying the particular solver backend. // // Different solvers likely have different invariants, and likely will not // have the same result sets for any particular inputs. Name() string // Version returns an int indicating the version of the solver of the given // Name(). Implementations should change their reported version ONLY when // the logic is changed in such a way that substantially changes the result // set that is possible for a substantial subset of likely inputs. // // "Substantial" is an imprecise term, and it is used intentionally. There // are no easy, general ways of subdividing constraint solving problems such // that one can know, a priori, the full impact that subtle algorithmic // changes will have on possible result sets. Consequently, we have to fall // back on coarser, intuition-based reasoning as to whether a change is // large enough that it is likely to be broadly user-visible. // // This is acceptable, because this value is not used programmatically by // the solver in any way. Rather, it is intend for implementing tools to // use as a coarse signal to users about compatibility between their tool's // version and the current data, typically via persistence to a Lock. // Changes to the version number reported should be weighed between // confusing teams by having two members' tools continuously rolling back // each others' chosen Solutions for no apparent reason, and annoying teams // by changing the number for changes so remote that warnings about solver // version mismatches become meaningless. // // Err on the side of caution. // // Chronology is the only implication of the ordering - that lower version // numbers were published before higher numbers. Version() int } func (s *solver) Name() string { return "gps-cdcl" } func (s *solver) Version() int { return 1 } // DeductionErrs maps package import path to errors occurring during deduction. type DeductionErrs map[string]error func (e DeductionErrs) Error() string { return "could not deduce external imports' project roots" } // ValidateParams validates the solver parameters to ensure solving can be completed. func ValidateParams(params SolveParameters, sm SourceManager) error { // Ensure that all packages are deducible without issues. var deducePkgsGroup sync.WaitGroup deductionErrs := make(DeductionErrs) var errsMut sync.Mutex rd, err := params.toRootdata() if err != nil { return err } deducePkg := func(ip string, sm SourceManager) { _, err := sm.DeduceProjectRoot(ip) if err != nil { errsMut.Lock() deductionErrs[ip] = err errsMut.Unlock() } deducePkgsGroup.Done() } for _, ip := range rd.externalImportList(paths.IsStandardImportPath) { deducePkgsGroup.Add(1) go deducePkg(ip, sm) } deducePkgsGroup.Wait() if len(deductionErrs) > 0 { return deductionErrs } return nil } // Solve attempts to find a dependency solution for the given project, as // represented by the SolveParameters with which this Solver was created. // // This is the entry point to the main gps workhorse. func (s *solver) Solve(ctx context.Context) (Solution, error) { // Solving can only be run once per solver. if !atomic.CompareAndSwapInt32(&s.hasrun, 0, 1) { return nil, errors.New("solve method can only be run once per instance") } // Make sure the bridge has the context before we start. //s.b.ctx = ctx // Set up a metrics object s.mtr = newMetrics() // Prime the queues with the root project if err := s.selectRoot(); err != nil { return nil, err } all, err := s.solve(ctx) s.mtr.pop() var soln solution if err == nil { soln = solution{ att: s.attempts, solv: s, } soln.analyzerInfo = s.rd.an.Info() soln.i = s.rd.externalImportList(s.stdLibFn) // Convert ProjectAtoms into LockedProjects soln.p = make([]LockedProject, 0, len(all)) for pa, pl := range all { lp := pa2lp(pa, pl) // Pass back the original inputlp directly if it Eqs what was // selected. if inputlp, has := s.rd.rlm[lp.Ident().ProjectRoot]; has && lp.Eq(inputlp) { lp = inputlp } soln.p = append(soln.p, lp) } } s.traceFinish(soln, err) if s.tl != nil { s.mtr.dump(s.tl) } return soln, err } // solve is the top-level loop for the solving process. func (s *solver) solve(ctx context.Context) (map[atom]map[string]struct{}, error) { // Pull out the donechan once up front so that we're not potentially // triggering mutex cycling and channel creation on each iteration. donechan := ctx.Done() // Main solving loop for { select { case <-donechan: return nil, ctx.Err() default: } bmi, has := s.nextUnselected() if !has { // no more packages to select - we're done. break } // This split is the heart of "bimodal solving": we follow different // satisfiability and selection paths depending on whether we've already // selected the base project/repo that came off the unselected queue. // // (If we've already selected the project, other parts of the algorithm // guarantee the bmi will contain at least one package from this project // that has yet to be selected.) if awp, is := s.sel.selected(bmi.id); !is { s.mtr.push("new-atom") // Analysis path for when we haven't selected the project yet - need // to create a version queue. queue, err := s.createVersionQueue(bmi) if err != nil { s.mtr.pop() // Err means a failure somewhere down the line; try backtracking. s.traceStartBacktrack(bmi, err, false) success, berr := s.backtrack(ctx) if berr != nil { err = berr } else if success { // backtracking succeeded, move to the next unselected id continue } return nil, err } if queue.current() == nil { panic("canary - queue is empty, but flow indicates success") } awp := atomWithPackages{ a: atom{ id: queue.id, v: queue.current(), }, pl: bmi.pl, } err = s.selectAtom(awp, false) s.mtr.pop() if err != nil { // Only a released SourceManager should be able to cause this. return nil, err } s.vqs = append(s.vqs, queue) } else { s.mtr.push("add-atom") // We're just trying to add packages to an already-selected project. // That means it's not OK to burn through the version queue for that // project as we do when first selecting a project, as doing so // would upend the guarantees on which all previous selections of // the project are based (both the initial one, and any package-only // ones). // Because we can only safely operate within the scope of the // single, currently selected version, we can skip looking for the // queue and just use the version given in what came back from // s.sel.selected(). nawp := atomWithPackages{ a: atom{ id: bmi.id, v: awp.a.v, }, pl: bmi.pl, } s.traceCheckPkgs(bmi) err := s.check(nawp, true) if err != nil { s.mtr.pop() // Err means a failure somewhere down the line; try backtracking. s.traceStartBacktrack(bmi, err, true) success, berr := s.backtrack(ctx) if berr != nil { err = berr } else if success { // backtracking succeeded, move to the next unselected id continue } return nil, err } err = s.selectAtom(nawp, true) s.mtr.pop() if err != nil { // Only a released SourceManager should be able to cause this. return nil, err } // We don't add anything to the stack of version queues because the // backtracker knows not to pop the vqstack if it backtracks // across a pure-package addition. } } // Getting this far means we successfully found a solution. Combine the // selected projects and packages. projs := make(map[atom]map[string]struct{}) // Skip the first project. It's always the root, and that shouldn't be // included in results. for _, sel := range s.sel.projects[1:] { pm, exists := projs[sel.a.a] if !exists { pm = make(map[string]struct{}) projs[sel.a.a] = pm } for _, path := range sel.a.pl { pm[path] = struct{}{} } } return projs, nil } // selectRoot is a specialized selectAtom, used solely to initially // populate the queues at the beginning of a solve run. func (s *solver) selectRoot() error { s.mtr.push("select-root") // Push the root project onto the queue. awp := s.rd.rootAtom() s.sel.pushSelection(awp, false) // If we're looking for root's deps, get it from opts and local root // analysis, rather than having the sm do it. deps, err := s.intersectConstraintsWithImports(s.rd.combineConstraints(), s.rd.externalImportList(s.stdLibFn)) if err != nil { if contextCanceledOrSMReleased(err) { return err } // TODO(sdboyer) this could well happen; handle it with a more graceful error panic(fmt.Sprintf("canary - shouldn't be possible %s", err)) } for _, dep := range deps { // If we have no lock, or if this dep isn't in the lock, then prefetch // it. See longer explanation in selectAtom() for how we benefit from // parallelism here. if s.rd.needVersionsFor(dep.Ident.ProjectRoot) { go s.b.SyncSourceFor(dep.Ident) } s.sel.pushDep(dependency{depender: awp.a, dep: dep}) // Add all to unselected queue heap.Push(s.unsel, bimodalIdentifier{id: dep.Ident, pl: dep.pl, fromRoot: true}) } s.traceSelectRoot(s.rd.rpt, deps) s.mtr.pop() return nil } func (s *solver) getImportsAndConstraintsOf(a atomWithPackages) ([]string, []completeDep, error) { var err error if s.rd.isRoot(a.a.id.ProjectRoot) { panic("Should never need to recheck imports/constraints from root during solve") } // Work through the source manager to get project info and static analysis // information. m, _, err := s.b.GetManifestAndLock(a.a.id, a.a.v, s.rd.an) if err != nil { return nil, nil, err } ptree, err := s.b.ListPackages(a.a.id, a.a.v) if err != nil { return nil, nil, err } rm, em := ptree.ToReachMap(true, false, true, s.rd.ir) // Use maps to dedupe the unique internal and external packages. exmap, inmap := make(map[string]struct{}), make(map[string]struct{}) for _, pkg := range a.pl { inmap[pkg] = struct{}{} for _, ipkg := range rm[pkg].Internal { inmap[ipkg] = struct{}{} } } var pl []string // If lens are the same, then the map must have the same contents as the // slice; no need to build a new one. if len(inmap) == len(a.pl) { pl = a.pl } else { pl = make([]string, 0, len(inmap)) for pkg := range inmap { pl = append(pl, pkg) } sort.Strings(pl) } // Add to the list those packages that are reached by the packages // explicitly listed in the atom for _, pkg := range a.pl { // Skip ignored packages if s.rd.ir.IsIgnored(pkg) { continue } ie, exists := rm[pkg] if !exists { // Missing package here *should* only happen if the target pkg was // poisoned; check the errors map. if importErr, eexists := em[pkg]; eexists { return nil, nil, importErr } // Nope, it's actually full-on not there. return nil, nil, fmt.Errorf("package %s does not exist within project %s", pkg, a.a.id) } for _, ex := range ie.External { exmap[ex] = struct{}{} } } reach := make([]string, 0, len(exmap)) for pkg := range exmap { reach = append(reach, pkg) } sort.Strings(reach) deps := s.rd.ovr.overrideAll(m.DependencyConstraints()) cd, err := s.intersectConstraintsWithImports(deps, reach) return pl, cd, err } // intersectConstraintsWithImports takes a list of constraints and a list of // externally reached packages, and creates a []completeDep that is guaranteed // to include all packages named by import reach, using constraints where they // are available, or Any() where they are not. func (s *solver) intersectConstraintsWithImports(deps []workingConstraint, reach []string) ([]completeDep, error) { // Create a radix tree with all the projects we know from the manifest xt := radix.New() for _, dep := range deps { xt.Insert(string(dep.Ident.ProjectRoot), dep) } // Step through the reached packages; if they have prefix matches in // the trie, assume (mostly) it's a correct correspondence. dmap := make(map[ProjectRoot]completeDep) for _, rp := range reach { // If it's a stdlib-shaped package, skip it. if s.stdLibFn(rp) { continue } // Look for a prefix match; it'll be the root project/repo containing // the reached package if pre, idep, match := xt.LongestPrefix(rp); match && isPathPrefixOrEqual(pre, rp) { // Match is valid; put it in the dmap, either creating a new // completeDep or appending it to the existing one for this base // project/prefix. dep := idep.(workingConstraint) if cdep, exists := dmap[dep.Ident.ProjectRoot]; exists { cdep.pl = append(cdep.pl, rp) dmap[dep.Ident.ProjectRoot] = cdep } else { dmap[dep.Ident.ProjectRoot] = completeDep{ workingConstraint: dep, pl: []string{rp}, } } continue } // No match. Let the SourceManager try to figure out the root root, err := s.b.DeduceProjectRoot(rp) if err != nil { // Nothing we can do if we can't suss out a root return nil, err } // Make a new completeDep with an open constraint, respecting overrides pd := s.rd.ovr.override(root, ProjectProperties{Constraint: Any()}) // Insert the pd into the trie so that further deps from this // project get caught by the prefix search xt.Insert(string(root), pd) // And also put the complete dep into the dmap dmap[root] = completeDep{ workingConstraint: pd, pl: []string{rp}, } } // Dump all the deps from the map into the expected return slice cdeps := make([]completeDep, 0, len(dmap)) for _, cdep := range dmap { cdeps = append(cdeps, cdep) } return cdeps, nil } func (s *solver) createVersionQueue(bmi bimodalIdentifier) (*versionQueue, error) { id := bmi.id // If on the root package, there's no queue to make if s.rd.isRoot(id.ProjectRoot) { return newVersionQueue(id, nil, nil, s.b) } exists, err := s.b.SourceExists(id) if err != nil { return nil, err } if !exists { exists, err = s.b.vendorCodeExists(id) if err != nil { return nil, err } if exists { // Project exists only in vendor // FIXME(sdboyer) this just totally doesn't work at all right now } else { return nil, fmt.Errorf("project '%s' could not be located", id) } } var lockv Version if len(s.rd.rlm) > 0 { lockv, err = s.getLockVersionIfValid(id) if err != nil { // Can only get an error here if an upgrade was expressly requested on // code that exists only in vendor return nil, err } } var prefv Version if bmi.fromRoot { // If this bmi came from the root, then we want to search through things // with a dependency on it in order to see if any have a lock that might // express a prefv // // TODO(sdboyer) nested loop; prime candidate for a cache somewhere for _, dep := range s.sel.getDependenciesOn(bmi.id) { // Skip the root, of course if s.rd.isRoot(dep.depender.id.ProjectRoot) { continue } _, l, err := s.b.GetManifestAndLock(dep.depender.id, dep.depender.v, s.rd.an) if err != nil || l == nil { // err being non-nil really shouldn't be possible, but the lock // being nil is quite likely continue } for _, lp := range l.Projects() { if lp.Ident().eq(bmi.id) { prefv = lp.Version() } } } // OTHER APPROACH - WRONG, BUT MAYBE USEFUL FOR REFERENCE? // If this bmi came from the root, then we want to search the unselected // queue to see if anything *else* wants this ident, in which case we // pick up that prefv //for _, bmi2 := range s.unsel.sl { //// Take the first thing from the queue that's for the same ident, //// and has a non-nil prefv //if bmi.id.eq(bmi2.id) { //if bmi2.prefv != nil { //prefv = bmi2.prefv //} //} //} } else { // Otherwise, just use the preferred version expressed in the bmi prefv = bmi.prefv } q, err := newVersionQueue(id, lockv, prefv, s.b) if err != nil { // TODO(sdboyer) this particular err case needs to be improved to be ONLY for cases // where there's absolutely nothing findable about a given project name return nil, err } // Hack in support for revisions. // // By design, revs aren't returned from ListVersion(). Thus, if the dep in // the bmi was has a rev constraint, it is (almost) guaranteed to fail, even // if that rev does exist in the repo. So, detect a rev and push it into the // vq here, instead. // // Happily, the solver maintains the invariant that constraints on a given // ident cannot be incompatible, so we know that if we find one rev, then // any other deps will have to also be on that rev (or Any). // // TODO(sdboyer) while this does work, it bypasses the interface-implied guarantees // of the version queue, and is therefore not a great strategy for API // coherency. Folding this in to a formal interface would be better. if tc, ok := s.sel.getConstraint(bmi.id).(Revision); ok && q.pi[0] != tc { // We know this is the only thing that could possibly match, so put it // in at the front - if it isn't there already. // TODO(sdboyer) existence of the revision is guaranteed by checkRevisionExists(); restore that call. q.pi = append([]Version{tc}, q.pi...) } // Having assembled the queue, search it for a valid version. s.traceCheckQueue(q, bmi, false, 1) return q, s.findValidVersion(q, bmi.pl) } // findValidVersion walks through a versionQueue until it finds a version that // satisfies the constraints held in the current state of the solver. // // The satisfiability checks triggered from here are constrained to operate only // on those dependencies induced by the list of packages given in the second // parameter. func (s *solver) findValidVersion(q *versionQueue, pl []string) error { if nil == q.current() { // this case should not be reachable, but reflects improper solver state // if it is, so panic immediately panic("version queue is empty, should not happen: " + string(q.id.ProjectRoot) + " " + q.id.Source) } faillen := len(q.fails) for { cur := q.current() s.traceInfo("try %s@%s", q.id, cur) err := s.check(atomWithPackages{ a: atom{ id: q.id, v: cur, }, pl: pl, }, false) if err == nil { // we have a good version, can return safely return nil } if q.advance(err) != nil { // Error on advance, have to bail out break } if q.isExhausted() { // Queue is empty, bail with error break } } s.fail(s.sel.getDependenciesOn(q.id)[0].depender.id) // Return a compound error of all the new errors encountered during this // attempt to find a new, valid version return &noVersionError{ pn: q.id, fails: q.fails[faillen:], } } // getLockVersionIfValid finds an atom for the given ProjectIdentifier from the // root lock, assuming: // // 1. A root lock was provided // 2. The general flag to change all projects was not passed // 3. A flag to change this particular ProjectIdentifier was not passed // // If any of these three conditions are true (or if the id cannot be found in // the root lock), then no atom will be returned. func (s *solver) getLockVersionIfValid(id ProjectIdentifier) (Version, error) { // If the project is specifically marked for changes, then don't look for a // locked version. if _, explicit := s.rd.chng[id.ProjectRoot]; explicit || s.rd.chngall { // For projects with an upstream or cache repository, it's safe to // ignore what's in the lock, because there's presumably more versions // to be found and attempted in the repository. If it's only in vendor, // though, then we have to try to use what's in the lock, because that's // the only version we'll be able to get. if exist, _ := s.b.SourceExists(id); exist { // Upgrades mean breaking the lock s.b.breakLock() return nil, nil } // However, if a change was *expressly* requested for something that // exists only in vendor, then that guarantees we don't have enough // information to complete a solution. In that case, error out. if explicit { return nil, &missingSourceFailure{ goal: id, prob: "Cannot upgrade %s, as no source repository could be found.", } } } lp, exists := s.rd.rlm[id.ProjectRoot] if !exists { return nil, nil } constraint := s.sel.getConstraint(id) v := lp.Version() if !constraint.Matches(v) { // No match found, which means we're going to be breaking the lock // Still return the invalid version so that is included in the trace s.b.breakLock() } return v, nil } // backtrack works backwards from the current failed solution to find the next // solution to try. func (s *solver) backtrack(ctx context.Context) (bool, error) { if len(s.vqs) == 0 { // nothing to backtrack to return false, nil } donechan := ctx.Done() s.mtr.push("backtrack") defer s.mtr.pop() for { for { select { case <-donechan: return false, ctx.Err() default: } if len(s.vqs) == 0 { // no more versions, nowhere further to backtrack return false, nil } if s.vqs[len(s.vqs)-1].failed { break } s.vqs, s.vqs[len(s.vqs)-1] = s.vqs[:len(s.vqs)-1], nil // Pop selections off until we get to a project. var proj bool var awp atomWithPackages for !proj { var err error awp, proj, err = s.unselectLast() if err != nil { if !contextCanceledOrSMReleased(err) { panic(fmt.Sprintf("canary - should only have been able to get a context cancellation or SM release, got %T %s", err, err)) } return false, err } s.traceBacktrack(awp.bmi(), !proj) } } // Grab the last versionQueue off the list of queues q := s.vqs[len(s.vqs)-1] // Walk back to the next project. This may entail walking through some // package-only selections. var proj bool var awp atomWithPackages for !proj { var err error awp, proj, err = s.unselectLast() if err != nil { if !contextCanceledOrSMReleased(err) { panic(fmt.Sprintf("canary - should only have been able to get a context cancellation or SM release, got %T %s", err, err)) } return false, err } s.traceBacktrack(awp.bmi(), !proj) } if !q.id.eq(awp.a.id) { panic("canary - version queue stack and selected project stack are misaligned") } // Advance the queue past the current version, which we know is bad // TODO(sdboyer) is it feasible to make available the failure reason here? if q.advance(nil) == nil && !q.isExhausted() { // Search for another acceptable version of this failed dep in its queue s.traceCheckQueue(q, awp.bmi(), true, 0) if s.findValidVersion(q, awp.pl) == nil { // Found one! Put it back on the selected queue and stop // backtracking // reusing the old awp is fine awp.a.v = q.current() err := s.selectAtom(awp, false) if err != nil { if !contextCanceledOrSMReleased(err) { panic(fmt.Sprintf("canary - should only have been able to get a context cancellation or SM release, got %T %s", err, err)) } return false, err } break } } s.traceBacktrack(awp.bmi(), false) // No solution found; continue backtracking after popping the queue // we just inspected off the list // GC-friendly pop pointer elem in slice s.vqs, s.vqs[len(s.vqs)-1] = s.vqs[:len(s.vqs)-1], nil } // Backtracking was successful if loop ended before running out of versions if len(s.vqs) == 0 { return false, nil } s.attempts++ return true, nil } func (s *solver) nextUnselected() (bimodalIdentifier, bool) { if len(s.unsel.sl) > 0 { return s.unsel.sl[0], true } return bimodalIdentifier{}, false } func (s *solver) unselectedComparator(i, j int) bool { ibmi, jbmi := s.unsel.sl[i], s.unsel.sl[j] iname, jname := ibmi.id, jbmi.id // Most important thing is pushing package additions ahead of project // additions. Package additions can't walk their version queue, so all they // do is narrow the possibility of success; better to find out early and // fast if they're going to fail than wait until after we've done real work // on a project and have to backtrack across it. // FIXME the impl here is currently O(n) in the number of selections; it // absolutely cannot stay in a hot sorting path like this // FIXME while other solver invariants probably protect us from it, this // call-out means that it's possible for external state change to invalidate // heap invariants. _, isel := s.sel.selected(iname) _, jsel := s.sel.selected(jname) if isel && !jsel { return true } if !isel && jsel { return false } if iname.eq(jname) { return false } _, ilock := s.rd.rlm[iname.ProjectRoot] _, jlock := s.rd.rlm[jname.ProjectRoot] switch { case ilock && !jlock: return true case !ilock && jlock: return false case ilock && jlock: return iname.Less(jname) } // Now, sort by number of available versions. This will trigger network // activity, but at this point we know that the project we're looking at // isn't locked by the root. And, because being locked by root is the only // way avoid that call when making a version queue, we know we're gonna have // to pay that cost anyway. // We can safely ignore an err from listVersions here because, if there is // an actual problem, it'll be noted and handled somewhere else saner in the // solving algorithm. ivl, _ := s.b.listVersions(iname) jvl, _ := s.b.listVersions(jname) iv, jv := len(ivl), len(jvl) // Packages with fewer versions to pick from are less likely to benefit from // backtracking, so deal with them earlier in order to minimize the amount // of superfluous backtracking through them we do. switch { case iv == 0 && jv != 0: return true case iv != 0 && jv == 0: return false case iv != jv: return iv < jv } // Finally, if all else fails, fall back to comparing by name return iname.Less(jname) } func (s *solver) fail(id ProjectIdentifier) { // TODO(sdboyer) does this need updating, now that we have non-project package // selection? // skip if the root project if !s.rd.isRoot(id.ProjectRoot) { // just look for the first (oldest) one; the backtracker will necessarily // traverse through and pop off any earlier ones for _, vq := range s.vqs { if vq.id.eq(id) { vq.failed = true return } } } } // selectAtom pulls an atom into the selection stack, alongside some of // its contained packages. New resultant dependency requirements are added to // the unselected priority queue. // // Behavior is slightly diffferent if pkgonly is true. func (s *solver) selectAtom(a atomWithPackages, pkgonly bool) error { s.mtr.push("select-atom") s.unsel.remove(bimodalIdentifier{ id: a.a.id, pl: a.pl, }) pl, deps, err := s.getImportsAndConstraintsOf(a) if err != nil { if contextCanceledOrSMReleased(err) { return err } // This shouldn't be possible; other checks should have ensured all // packages and deps are present for any argument passed to this method. panic(fmt.Sprintf("canary - shouldn't be possible %s", err)) } // Assign the new internal package list into the atom, then push it onto the // selection stack a.pl = pl s.sel.pushSelection(a, pkgonly) // If this atom has a lock, pull it out so that we can potentially inject // preferred versions into any bmis we enqueue // // TODO(sdboyer) making this call here could be the first thing to trigger // network activity...maybe? if so, can we mitigate by deferring the work to // queue consumption time? _, l, _ := s.b.GetManifestAndLock(a.a.id, a.a.v, s.rd.an) var lmap map[ProjectIdentifier]Version if l != nil { lmap = make(map[ProjectIdentifier]Version) for _, lp := range l.Projects() { lmap[lp.Ident()] = lp.Version() } } for _, dep := range deps { // Root can come back up here if there's a project-level cycle. // Satisfiability checks have already ensured invariants are maintained, // so we know we can just skip it here. if s.rd.isRoot(dep.Ident.ProjectRoot) { continue } // If this is dep isn't in the lock, do some prefetching. (If it is, we // might be able to get away with zero network activity for it, so don't // prefetch). This provides an opportunity for some parallelism wins, on // two fronts: // // 1. Because this loop may have multiple deps in it, we could end up // simultaneously fetching both in the background while solving proceeds // // 2. Even if only one dep gets prefetched here, the worst case is that // that same dep comes out of the unselected queue next, and we gain a // few microseconds before blocking later. Best case, the dep doesn't // come up next, but some other dep comes up that wasn't prefetched, and // both fetches proceed in parallel. if s.rd.needVersionsFor(dep.Ident.ProjectRoot) { go s.b.SyncSourceFor(dep.Ident) } s.sel.pushDep(dependency{depender: a.a, dep: dep}) // Go through all the packages introduced on this dep, selecting only // the ones where the only depper on them is what the preceding line just // pushed in. Then, put those into the unselected queue. rpm := s.sel.getRequiredPackagesIn(dep.Ident) var newp []string for _, pkg := range dep.pl { // Just one means that the dep we're visiting is the sole importer. if rpm[pkg] == 1 { newp = append(newp, pkg) } } if len(newp) > 0 { // If there was a previously-established alternate source for this // dependency, but the current atom did not express one (and getting // here means the atom passed the source hot-swapping check - see // checkIdentMatches()), then we have to create the new bmi with the // alternate source. Otherwise, we end up with two discrete project // entries for the project root in the final output, one with the // alternate source, and one without. See #969. id, _ := s.sel.getIdentFor(dep.Ident.ProjectRoot) bmi := bimodalIdentifier{ id: id, pl: newp, // This puts in a preferred version if one's in the map, else // drops in the zero value (nil) prefv: lmap[dep.Ident], } heap.Push(s.unsel, bmi) } } s.traceSelect(a, pkgonly) s.mtr.pop() return nil } func (s *solver) unselectLast() (atomWithPackages, bool, error) { s.mtr.push("unselect") defer s.mtr.pop() awp, first := s.sel.popSelection() heap.Push(s.unsel, bimodalIdentifier{id: awp.a.id, pl: awp.pl}) _, deps, err := s.getImportsAndConstraintsOf(awp) if err != nil { if contextCanceledOrSMReleased(err) { return atomWithPackages{}, false, err } // This shouldn't be possible; other checks should have ensured all // packages and deps are present for any argument passed to this method. panic(fmt.Sprintf("canary - shouldn't be possible %s", err)) } for _, dep := range deps { // Skip popping if the dep is the root project, which can occur if // there's a project-level import cycle. (This occurs frequently with // e.g. kubernetes and docker) if s.rd.isRoot(dep.Ident.ProjectRoot) { continue } s.sel.popDep(dep.Ident) // if no parents/importers, remove from unselected queue if s.sel.depperCount(dep.Ident) == 0 { s.unsel.remove(bimodalIdentifier{id: dep.Ident, pl: dep.pl}) } } return awp, first, nil } // simple (temporary?) helper just to convert atoms into locked projects func pa2lp(pa atom, pkgs map[string]struct{}) LockedProject { lp := lockedProject{ pi: pa.id, } switch v := pa.v.(type) { case UnpairedVersion: lp.v = v case Revision: lp.r = v case versionPair: lp.v = v.v lp.r = v.r default: panic("unreachable") } lp.pkgs = make([]string, 0, len(pkgs)) pr := string(pa.id.ProjectRoot) trim := pr + "/" for pkg := range pkgs { if pkg == string(pa.id.ProjectRoot) { lp.pkgs = append(lp.pkgs, ".") } else { lp.pkgs = append(lp.pkgs, strings.TrimPrefix(pkg, trim)) } } sort.Strings(lp.pkgs) return lp } func contextCanceledOrSMReleased(err error) bool { return err == context.Canceled || err == context.DeadlineExceeded || err == ErrSourceManagerIsReleased }
dep/gps/solver.go/0
{ "file_path": "dep/gps/solver.go", "repo_id": "dep", "token_count": 14966 }
33
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gps import ( "fmt" "strconv" "strings" "github.com/golang/dep/gps/pkgtree" ) const ( successChar = "✓" successCharSp = successChar + " " failChar = "✗" failCharSp = failChar + " " backChar = "←" innerIndent = " " ) func (s *solver) traceCheckPkgs(bmi bimodalIdentifier) { if s.tl == nil { return } prefix := getprei(len(s.vqs) + 1) s.tl.Printf("%s\n", tracePrefix(fmt.Sprintf("? revisit %s to add %v pkgs", bmi.id, len(bmi.pl)), prefix, prefix)) } func (s *solver) traceCheckQueue(q *versionQueue, bmi bimodalIdentifier, cont bool, offset int) { if s.tl == nil { return } prefix := getprei(len(s.vqs) + offset) vlen := strconv.Itoa(len(q.pi)) if !q.allLoaded { vlen = "at least " + vlen } // TODO(sdboyer) how...to list the packages in the limited space we have? var verb string indent := "" if cont { // Continue is an "inner" message.. indenting verb = "continue" vlen += " more" indent = innerIndent } else { verb = "attempt" } s.tl.Printf("%s\n", tracePrefix(fmt.Sprintf("%s? %s %s with %v pkgs; %s versions to try", indent, verb, bmi.id, len(bmi.pl), vlen), prefix, prefix)) } // traceStartBacktrack is called with the bmi that first failed, thus initiating // backtracking func (s *solver) traceStartBacktrack(bmi bimodalIdentifier, err error, pkgonly bool) { if s.tl == nil { return } var msg string if pkgonly { msg = fmt.Sprintf("%s%s could not add %v pkgs to %s; begin backtrack", innerIndent, backChar, len(bmi.pl), bmi.id) } else { msg = fmt.Sprintf("%s%s no more versions of %s to try; begin backtrack", innerIndent, backChar, bmi.id) } prefix := getprei(len(s.sel.projects)) s.tl.Printf("%s\n", tracePrefix(msg, prefix, prefix)) } // traceBacktrack is called when a package or project is poppped off during // backtracking func (s *solver) traceBacktrack(bmi bimodalIdentifier, pkgonly bool) { if s.tl == nil { return } var msg string if pkgonly { msg = fmt.Sprintf("%s backtrack: popped %v pkgs from %s", backChar, len(bmi.pl), bmi.id) } else { msg = fmt.Sprintf("%s backtrack: no more versions of %s to try", backChar, bmi.id) } prefix := getprei(len(s.sel.projects)) s.tl.Printf("%s\n", tracePrefix(msg, prefix, prefix)) } // Called just once after solving has finished, whether success or not func (s *solver) traceFinish(sol solution, err error) { if s.tl == nil { return } if err == nil { var pkgcount int for _, lp := range sol.Projects() { pkgcount += len(lp.Packages()) } s.tl.Printf("%s%s found solution with %v packages from %v projects", innerIndent, successChar, pkgcount, len(sol.Projects())) } else { s.tl.Printf("%s%s solving failed", innerIndent, failChar) } } // traceSelectRoot is called just once, when the root project is selected func (s *solver) traceSelectRoot(ptree pkgtree.PackageTree, cdeps []completeDep) { if s.tl == nil { return } // This duplicates work a bit, but we're in trace mode and it's only once, // so who cares rm, _ := ptree.ToReachMap(true, true, false, s.rd.ir) s.tl.Printf("Root project is %q", s.rd.rpt.ImportRoot) var expkgs int for _, cdep := range cdeps { expkgs += len(cdep.pl) } // TODO(sdboyer) include info on ignored pkgs/imports, etc. s.tl.Printf(" %v transitively valid internal packages", len(rm)) s.tl.Printf(" %v external packages imported from %v projects", expkgs, len(cdeps)) s.tl.Printf("(0) " + successCharSp + "select (root)") } // traceSelect is called when an atom is successfully selected func (s *solver) traceSelect(awp atomWithPackages, pkgonly bool) { if s.tl == nil { return } var msg string if pkgonly { msg = fmt.Sprintf("%s%s include %v more pkgs from %s", innerIndent, successChar, len(awp.pl), a2vs(awp.a)) } else { msg = fmt.Sprintf("%s select %s w/%v pkgs", successChar, a2vs(awp.a), len(awp.pl)) } prefix := getprei(len(s.sel.projects) - 1) s.tl.Printf("%s\n", tracePrefix(msg, prefix, prefix)) } func (s *solver) traceInfo(args ...interface{}) { if s.tl == nil { return } if len(args) == 0 { panic("must pass at least one param to traceInfo") } preflen := len(s.sel.projects) var msg string switch data := args[0].(type) { case string: msg = tracePrefix(innerIndent+fmt.Sprintf(data, args[1:]...), " ", " ") case traceError: preflen++ // We got a special traceError, use its custom method msg = tracePrefix(innerIndent+data.traceString(), " ", failCharSp) case error: // Regular error; still use the x leader but default Error() string msg = tracePrefix(innerIndent+data.Error(), " ", failCharSp) default: // panic here because this can *only* mean a stupid internal bug panic(fmt.Sprintf("canary - unknown type passed as first param to traceInfo %T", data)) } prefix := getprei(preflen) s.tl.Printf("%s\n", tracePrefix(msg, prefix, prefix)) } func getprei(i int) string { var s string if i < 10 { s = fmt.Sprintf("(%d) ", i) } else if i < 100 { s = fmt.Sprintf("(%d) ", i) } else { s = fmt.Sprintf("(%d) ", i) } return s } func tracePrefix(msg, sep, fsep string) string { parts := strings.Split(strings.TrimSuffix(msg, "\n"), "\n") for k, str := range parts { if k == 0 { parts[k] = fsep + str } else { parts[k] = sep + str } } return strings.Join(parts, "\n") }
dep/gps/trace.go/0
{ "file_path": "dep/gps/trace.go", "repo_id": "dep", "token_count": 2175 }
34
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package verify import ( "strings" "testing" "github.com/golang/dep/gps" "github.com/golang/dep/gps/pkgtree" ) type lockUnsatisfactionDimension uint8 const ( noLock lockUnsatisfactionDimension = 1 << iota missingImports excessImports unmatchedOverrides unmatchedConstraints ) func (lsd lockUnsatisfactionDimension) String() string { var parts []string for i := uint(0); i < 5; i++ { if lsd&(1<<i) != 0 { switch lsd { case noLock: parts = append(parts, "no lock") case missingImports: parts = append(parts, "missing imports") case excessImports: parts = append(parts, "excess imports") case unmatchedOverrides: parts = append(parts, "unmatched overrides") case unmatchedConstraints: parts = append(parts, "unmatched constraints") } } } return strings.Join(parts, ", ") } func TestLockSatisfaction(t *testing.T) { fooversion := gps.NewVersion("v1.0.0").Pair("foorev1") bazversion := gps.NewVersion("v2.0.0").Pair("bazrev1") transver := gps.NewVersion("v0.5.0").Pair("transrev1") l := safeLock{ i: []string{"foo.com/bar", "baz.com/qux"}, p: []gps.LockedProject{ newVerifiableProject(mkPI("foo.com/bar"), fooversion, []string{".", "subpkg"}), newVerifiableProject(mkPI("baz.com/qux"), bazversion, []string{".", "other"}), newVerifiableProject(mkPI("transitive.com/dependency"), transver, []string{"."}), }, } ptree := pkgtree.PackageTree{ ImportRoot: "current", Packages: map[string]pkgtree.PackageOrErr{ "current": { P: pkgtree.Package{ Name: "current", ImportPath: "current", Imports: []string{"foo.com/bar"}, }, }, }, } rm := simpleRootManifest{ req: map[string]bool{ "baz.com/qux": true, }, } var dup rootManifestTransformer = func(simpleRootManifest) simpleRootManifest { return rm.dup() } tt := map[string]struct { rmt rootManifestTransformer sat lockUnsatisfactionDimension checkfn func(*testing.T, LockSatisfaction) }{ "ident": { rmt: dup, }, "added import": { rmt: dup.addReq("fiz.com/wow"), sat: missingImports, }, "removed import": { rmt: dup.rmReq("baz.com/qux"), sat: excessImports, }, "added and removed import": { rmt: dup.rmReq("baz.com/qux").addReq("fiz.com/wow"), sat: excessImports | missingImports, checkfn: func(t *testing.T, lsat LockSatisfaction) { if lsat.MissingImports[0] != "fiz.com/wow" { t.Errorf("expected 'fiz.com/wow' as sole missing import, got %s", lsat.MissingImports) } if lsat.ExcessImports[0] != "baz.com/qux" { t.Errorf("expected 'baz.com/qux' as sole excess import, got %s", lsat.ExcessImports) } }, }, "acceptable constraint": { rmt: dup.setConstraint("baz.com/qux", bazversion.Unpair(), ""), }, "unacceptable constraint": { rmt: dup.setConstraint("baz.com/qux", fooversion.Unpair(), ""), sat: unmatchedConstraints, checkfn: func(t *testing.T, lsat LockSatisfaction) { pr := gps.ProjectRoot("baz.com/qux") unmet, has := lsat.UnmetConstraints[pr] if !has { t.Errorf("did not have constraint on expected project %q; map contents: %s", pr, lsat.UnmetConstraints) } if unmet.C != fooversion.Unpair() { t.Errorf("wanted %s for unmet constraint, got %s", fooversion.Unpair(), unmet.C) } if unmet.V != bazversion { t.Errorf("wanted %s for version that did not meet constraint, got %s", bazversion, unmet.V) } }, }, "acceptable override": { rmt: dup.setOverride("baz.com/qux", bazversion.Unpair(), ""), }, "unacceptable override": { rmt: dup.setOverride("baz.com/qux", fooversion.Unpair(), ""), sat: unmatchedOverrides, }, "ineffectual constraint": { rmt: dup.setConstraint("transitive.com/dependency", bazversion.Unpair(), ""), }, "transitive override": { rmt: dup.setOverride("transitive.com/dependency", bazversion.Unpair(), ""), sat: unmatchedOverrides, }, "ignores respected": { rmt: dup.addIgnore("foo.com/bar"), sat: excessImports, }, } for name, fix := range tt { fix := fix t.Run(name, func(t *testing.T) { fixrm := fix.rmt(rm) lsat := LockSatisfiesInputs(l, fixrm, ptree) gotsat := lsat.unsatTypes() if fix.sat & ^gotsat != 0 { t.Errorf("wanted unsat in some dimensions that were satisfied: %s", fix.sat & ^gotsat) } if gotsat & ^fix.sat != 0 { t.Errorf("wanted sat in some dimensions that were unsatisfied: %s", gotsat & ^fix.sat) } if lsat.Satisfied() && fix.sat != 0 { t.Errorf("Satisfied() incorrectly reporting true when expecting some dimensions to be unsatisfied: %s", fix.sat) } else if !lsat.Satisfied() && fix.sat == 0 { t.Error("Satisfied() incorrectly reporting false when expecting all dimensions to be satisfied") } if fix.checkfn != nil { fix.checkfn(t, lsat) } }) } var lsat LockSatisfaction if lsat.Satisfied() { t.Error("zero value of LockSatisfaction should fail") } if LockSatisfiesInputs(nil, nil, ptree).Satisfied() { t.Error("nil lock to LockSatisfiesInputs should produce failing result") } } func (ls LockSatisfaction) unsatTypes() lockUnsatisfactionDimension { var dims lockUnsatisfactionDimension if !ls.LockExisted { dims |= noLock } if len(ls.MissingImports) != 0 { dims |= missingImports } if len(ls.ExcessImports) != 0 { dims |= excessImports } if len(ls.UnmetOverrides) != 0 { dims |= unmatchedOverrides } if len(ls.UnmetConstraints) != 0 { dims |= unmatchedConstraints } return dims } type rootManifestTransformer func(simpleRootManifest) simpleRootManifest func (rmt rootManifestTransformer) compose(rmt2 rootManifestTransformer) rootManifestTransformer { if rmt == nil { return rmt2 } return func(rm simpleRootManifest) simpleRootManifest { return rmt2(rmt(rm)) } } func (rmt rootManifestTransformer) addReq(path string) rootManifestTransformer { return rmt.compose(func(rm simpleRootManifest) simpleRootManifest { rm.req[path] = true return rm }) } func (rmt rootManifestTransformer) rmReq(path string) rootManifestTransformer { return rmt.compose(func(rm simpleRootManifest) simpleRootManifest { delete(rm.req, path) return rm }) } func (rmt rootManifestTransformer) setConstraint(pr string, c gps.Constraint, source string) rootManifestTransformer { return rmt.compose(func(rm simpleRootManifest) simpleRootManifest { rm.c[gps.ProjectRoot(pr)] = gps.ProjectProperties{ Constraint: c, Source: source, } return rm }) } func (rmt rootManifestTransformer) setOverride(pr string, c gps.Constraint, source string) rootManifestTransformer { return rmt.compose(func(rm simpleRootManifest) simpleRootManifest { rm.ovr[gps.ProjectRoot(pr)] = gps.ProjectProperties{ Constraint: c, Source: source, } return rm }) } func (rmt rootManifestTransformer) addIgnore(path string) rootManifestTransformer { return rmt.compose(func(rm simpleRootManifest) simpleRootManifest { rm.ig = pkgtree.NewIgnoredRuleset(append(rm.ig.ToSlice(), path)) return rm }) }
dep/gps/verify/locksat_test.go/0
{ "file_path": "dep/gps/verify/locksat_test.go", "repo_id": "dep", "token_count": 2926 }
35
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package feedback import ( "bytes" "testing" "github.com/golang/dep/gps" ) // mkPI creates a ProjectIdentifier with the ProjectRoot as the provided // string, and the Source unset. // // Call normalize() on the returned value if you need the Source to be be // equal to the ProjectRoot. func mkPI(root string) gps.ProjectIdentifier { return gps.ProjectIdentifier{ ProjectRoot: gps.ProjectRoot(root), } } func TestStringDiff_NoChange(t *testing.T) { diff := StringDiff{Previous: "foo", Current: "foo"} want := "foo" got := diff.String() if got != want { t.Fatalf("Expected '%s', got '%s'", want, got) } } func TestStringDiff_Add(t *testing.T) { diff := StringDiff{Current: "foo"} got := diff.String() if got != "+ foo" { t.Fatalf("Expected '+ foo', got '%s'", got) } } func TestStringDiff_Remove(t *testing.T) { diff := StringDiff{Previous: "foo"} want := "- foo" got := diff.String() if got != want { t.Fatalf("Expected '%s', got '%s'", want, got) } } func TestStringDiff_Modify(t *testing.T) { diff := StringDiff{Previous: "foo", Current: "bar"} want := "foo -> bar" got := diff.String() if got != want { t.Fatalf("Expected '%s', got '%s'", want, got) } } func TestDiffProjects_NoChange(t *testing.T) { p1 := gps.NewLockedProject(mkPI("github.com/golang/dep/gps"), gps.NewVersion("v0.10.0"), []string{"gps"}) p2 := gps.NewLockedProject(mkPI("github.com/golang/dep/gps"), gps.NewVersion("v0.10.0"), []string{"gps"}) diff := DiffProjects(p1, p2) if diff != nil { t.Fatal("Expected the diff to be nil") } } func TestDiffProjects_Modify(t *testing.T) { p1 := gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewBranch("master").Pair("abc123"), []string{"baz", "qux"}) p2 := gps.NewLockedProject(gps.ProjectIdentifier{ProjectRoot: "github.com/foo/bar", Source: "https://github.com/mcfork/gps.git"}, gps.NewVersion("v1.0.0").Pair("def456"), []string{"baz", "derp"}) diff := DiffProjects(p1, p2) if diff == nil { t.Fatal("Expected the diff to be populated") } wantSource := "+ https://github.com/mcfork/gps.git" gotSource := diff.Source.String() if gotSource != wantSource { t.Fatalf("Expected diff.Source to be '%s', got '%s'", wantSource, diff.Source) } wantVersion := "+ v1.0.0" gotVersion := diff.Version.String() if gotVersion != wantVersion { t.Fatalf("Expected diff.Version to be '%s', got '%s'", wantVersion, gotVersion) } wantRevision := "abc123 -> def456" gotRevision := diff.Revision.String() if gotRevision != wantRevision { t.Fatalf("Expected diff.Revision to be '%s', got '%s'", wantRevision, gotRevision) } wantBranch := "- master" gotBranch := diff.Branch.String() if gotBranch != wantBranch { t.Fatalf("Expected diff.Branch to be '%s', got '%s'", wantBranch, gotBranch) } fmtPkgs := func(pkgs []StringDiff) string { b := bytes.NewBufferString("[") for _, pkg := range pkgs { b.WriteString(pkg.String()) b.WriteString(",") } b.WriteString("]") return b.String() } wantPackages := "[+ derp,- qux,]" gotPackages := fmtPkgs(diff.Packages) if gotPackages != wantPackages { t.Fatalf("Expected diff.Packages to be '%s', got '%s'", wantPackages, gotPackages) } } func TestDiffProjects_AddPackages(t *testing.T) { p1 := gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewBranch("master").Pair("abc123"), []string{"foobar"}) p2 := gps.NewLockedProject(gps.ProjectIdentifier{ProjectRoot: "github.com/foo/bar", Source: "https://github.com/mcfork/gps.git"}, gps.NewVersion("v1.0.0").Pair("def456"), []string{"bazqux", "foobar", "zugzug"}) diff := DiffProjects(p1, p2) if diff == nil { t.Fatal("Expected the diff to be populated") } if len(diff.Packages) != 2 { t.Fatalf("Expected diff.Packages to have 2 packages, got %d", len(diff.Packages)) } want0 := "+ bazqux" got0 := diff.Packages[0].String() if got0 != want0 { t.Fatalf("Expected diff.Packages[0] to contain %s, got %s", want0, got0) } want1 := "+ zugzug" got1 := diff.Packages[1].String() if got1 != want1 { t.Fatalf("Expected diff.Packages[1] to contain %s, got %s", want1, got1) } } func TestDiffProjects_RemovePackages(t *testing.T) { p1 := gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewBranch("master").Pair("abc123"), []string{"athing", "foobar"}) p2 := gps.NewLockedProject(gps.ProjectIdentifier{ProjectRoot: "github.com/foo/bar", Source: "https://github.com/mcfork/gps.git"}, gps.NewVersion("v1.0.0").Pair("def456"), []string{"bazqux"}) diff := DiffProjects(p1, p2) if diff == nil { t.Fatal("Expected the diff to be populated") } if len(diff.Packages) > 3 { t.Fatalf("Expected diff.Packages to have 3 packages, got %d", len(diff.Packages)) } want0 := "- athing" got0 := diff.Packages[0].String() if got0 != want0 { t.Fatalf("Expected diff.Packages[0] to contain %s, got %s", want0, got0) } // diff.Packages[1] is '+ bazqux' want2 := "- foobar" got2 := diff.Packages[2].String() if got2 != want2 { t.Fatalf("Expected diff.Packages[2] to contain %s, got %s", want2, got2) } } func TestDiffLocks_NoChange(t *testing.T) { l1 := gps.SimpleLock{ gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v1.0.0"), nil), } l2 := gps.SimpleLock{ gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v1.0.0"), nil), } diff := DiffLocks(l1, l2) if diff != nil { t.Fatal("Expected the diff to be nil") } } func TestDiffLocks_AddProjects(t *testing.T) { l1 := gps.SimpleLock{ gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v1.0.0"), nil), } l2 := gps.SimpleLock{ gps.NewLockedProject(gps.ProjectIdentifier{ProjectRoot: "github.com/baz/qux", Source: "https://github.com/mcfork/bazqux.git"}, gps.NewVersion("v0.5.0").Pair("def456"), []string{"p1", "p2"}), gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v1.0.0"), nil), gps.NewLockedProject(mkPI("github.com/zug/zug"), gps.NewVersion("v1.0.0"), nil), } diff := DiffLocks(l1, l2) if diff == nil { t.Fatal("Expected the diff to be populated") } if len(diff.Add) != 2 { t.Fatalf("Expected diff.Add to have 2 projects, got %d", len(diff.Add)) } want0 := "github.com/baz/qux" got0 := string(diff.Add[0].Name) if got0 != want0 { t.Fatalf("Expected diff.Add[0] to contain %s, got %s", want0, got0) } want1 := "github.com/zug/zug" got1 := string(diff.Add[1].Name) if got1 != want1 { t.Fatalf("Expected diff.Add[1] to contain %s, got %s", want1, got1) } add0 := diff.Add[0] wantSource := "https://github.com/mcfork/bazqux.git" gotSource := add0.Source.String() if gotSource != wantSource { t.Fatalf("Expected diff.Add[0].Source to be '%s', got '%s'", wantSource, add0.Source) } wantVersion := "v0.5.0" gotVersion := add0.Version.String() if gotVersion != wantVersion { t.Fatalf("Expected diff.Add[0].Version to be '%s', got '%s'", wantVersion, gotVersion) } wantRevision := "def456" gotRevision := add0.Revision.String() if gotRevision != wantRevision { t.Fatalf("Expected diff.Add[0].Revision to be '%s', got '%s'", wantRevision, gotRevision) } wantBranch := "" gotBranch := add0.Branch.String() if gotBranch != wantBranch { t.Fatalf("Expected diff.Add[0].Branch to be '%s', got '%s'", wantBranch, gotBranch) } fmtPkgs := func(pkgs []StringDiff) string { b := bytes.NewBufferString("[") for _, pkg := range pkgs { b.WriteString(pkg.String()) b.WriteString(",") } b.WriteString("]") return b.String() } wantPackages := "[p1,p2,]" gotPackages := fmtPkgs(add0.Packages) if gotPackages != wantPackages { t.Fatalf("Expected diff.Add[0].Packages to be '%s', got '%s'", wantPackages, gotPackages) } } func TestDiffLocks_RemoveProjects(t *testing.T) { l1 := gps.SimpleLock{ gps.NewLockedProject(gps.ProjectIdentifier{ProjectRoot: "github.com/a/thing", Source: "https://github.com/mcfork/athing.git"}, gps.NewBranch("master").Pair("def456"), []string{"p1", "p2"}), gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v1.0.0"), nil), } l2 := gps.SimpleLock{ gps.NewLockedProject(mkPI("github.com/baz/qux"), gps.NewVersion("v1.0.0"), nil), } diff := DiffLocks(l1, l2) if diff == nil { t.Fatal("Expected the diff to be populated") } if len(diff.Remove) != 2 { t.Fatalf("Expected diff.Remove to have 2 projects, got %d", len(diff.Remove)) } want0 := "github.com/a/thing" got0 := string(diff.Remove[0].Name) if got0 != want0 { t.Fatalf("Expected diff.Remove[0] to contain %s, got %s", want0, got0) } want1 := "github.com/foo/bar" got1 := string(diff.Remove[1].Name) if got1 != want1 { t.Fatalf("Expected diff.Remove[1] to contain %s, got %s", want1, got1) } remove0 := diff.Remove[0] wantSource := "https://github.com/mcfork/athing.git" gotSource := remove0.Source.String() if gotSource != wantSource { t.Fatalf("Expected diff.Remove[0].Source to be '%s', got '%s'", wantSource, remove0.Source) } wantVersion := "" gotVersion := remove0.Version.String() if gotVersion != wantVersion { t.Fatalf("Expected diff.Remove[0].Version to be '%s', got '%s'", wantVersion, gotVersion) } wantRevision := "def456" gotRevision := remove0.Revision.String() if gotRevision != wantRevision { t.Fatalf("Expected diff.Remove[0].Revision to be '%s', got '%s'", wantRevision, gotRevision) } wantBranch := "master" gotBranch := remove0.Branch.String() if gotBranch != wantBranch { t.Fatalf("Expected diff.Remove[0].Branch to be '%s', got '%s'", wantBranch, gotBranch) } fmtPkgs := func(pkgs []StringDiff) string { b := bytes.NewBufferString("[") for _, pkg := range pkgs { b.WriteString(pkg.String()) b.WriteString(",") } b.WriteString("]") return b.String() } wantPackages := "[p1,p2,]" gotPackages := fmtPkgs(remove0.Packages) if gotPackages != wantPackages { t.Fatalf("Expected diff.Remove[0].Packages to be '%s', got '%s'", wantPackages, gotPackages) } } func TestDiffLocks_ModifyProjects(t *testing.T) { l1 := gps.SimpleLock{ gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v1.0.0"), nil), gps.NewLockedProject(mkPI("github.com/foo/bu"), gps.NewVersion("v1.0.0"), nil), gps.NewLockedProject(mkPI("github.com/zig/zag"), gps.NewVersion("v1.0.0"), nil), } l2 := gps.SimpleLock{ gps.NewLockedProject(mkPI("github.com/baz/qux"), gps.NewVersion("v1.0.0"), nil), gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v2.0.0"), nil), gps.NewLockedProject(mkPI("github.com/zig/zag"), gps.NewVersion("v2.0.0"), nil), gps.NewLockedProject(mkPI("github.com/zug/zug"), gps.NewVersion("v1.0.0"), nil), } diff := DiffLocks(l1, l2) if diff == nil { t.Fatal("Expected the diff to be populated") } if len(diff.Modify) != 2 { t.Fatalf("Expected diff.Remove to have 2 projects, got %d", len(diff.Remove)) } want0 := "github.com/foo/bar" got0 := string(diff.Modify[0].Name) if got0 != want0 { t.Fatalf("Expected diff.Modify[0] to contain %s, got %s", want0, got0) } want1 := "github.com/zig/zag" got1 := string(diff.Modify[1].Name) if got1 != want1 { t.Fatalf("Expected diff.Modify[1] to contain %s, got %s", want1, got1) } } func TestDiffLocks_EmptyInitialLock(t *testing.T) { l2 := gps.SimpleLock{ gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v1.0.0"), nil), } diff := DiffLocks(nil, l2) if len(diff.Add) != 1 { t.Fatalf("Expected diff.Add to contain 1 project, got %d", len(diff.Add)) } } func TestDiffLocks_EmptyFinalLock(t *testing.T) { l1 := gps.SimpleLock{ gps.NewLockedProject(mkPI("github.com/foo/bar"), gps.NewVersion("v1.0.0"), nil), } diff := DiffLocks(l1, nil) if len(diff.Remove) != 1 { t.Fatalf("Expected diff.Remove to contain 1 project, got %d", len(diff.Remove)) } } func TestDiffLocks_EmptyLocks(t *testing.T) { diff := DiffLocks(nil, nil) if diff != nil { t.Fatal("Expected the diff to be empty") } }
dep/internal/feedback/lockdiff_test.go/0
{ "file_path": "dep/internal/feedback/lockdiff_test.go", "repo_id": "dep", "token_count": 4988 }
36
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package glock import ( "bufio" "fmt" "log" "os" "path/filepath" "strings" "github.com/golang/dep" "github.com/golang/dep/gps" "github.com/golang/dep/internal/importers/base" "github.com/pkg/errors" ) const glockfile = "GLOCKFILE" // Importer imports glock configuration into the dep configuration format. type Importer struct { *base.Importer packages []glockPackage } // NewImporter for glock. func NewImporter(logger *log.Logger, verbose bool, sm gps.SourceManager) *Importer { return &Importer{Importer: base.NewImporter(logger, verbose, sm)} } // Name of the importer. func (g *Importer) Name() string { return "glock" } // HasDepMetadata checks if a directory contains config that the importer can handle. func (g *Importer) HasDepMetadata(dir string) bool { path := filepath.Join(dir, glockfile) if _, err := os.Stat(path); err != nil { return false } return true } // Import the config found in the directory. func (g *Importer) Import(dir string, pr gps.ProjectRoot) (*dep.Manifest, *dep.Lock, error) { err := g.load(dir) if err != nil { return nil, nil, err } m, l := g.convert(pr) return m, l, nil } type glockPackage struct { importPath string revision string } func (g *Importer) load(projectDir string) error { g.Logger.Println("Detected glock configuration files...") path := filepath.Join(projectDir, glockfile) if g.Verbose { g.Logger.Printf(" Loading %s", path) } f, err := os.Open(path) if err != nil { return errors.Wrapf(err, "unable to open %s", path) } defer f.Close() scanner := bufio.NewScanner(f) for scanner.Scan() { pkg, err := parseGlockLine(scanner.Text()) if err != nil { g.Logger.Printf(" Warning: Skipping line. Unable to parse: %s\n", err) continue } if pkg == nil { continue } g.packages = append(g.packages, *pkg) } if err := scanner.Err(); err != nil { g.Logger.Printf(" Warning: Ignoring errors found while parsing %s: %s\n", path, err) } return nil } func parseGlockLine(line string) (*glockPackage, error) { fields := strings.Fields(line) switch len(fields) { case 2: // Valid. case 0: // Skip empty lines. return nil, nil default: return nil, fmt.Errorf("invalid glock configuration: %s", line) } // Skip commands. if fields[0] == "cmd" { return nil, nil } return &glockPackage{ importPath: fields[0], revision: fields[1], }, nil } func (g *Importer) convert(pr gps.ProjectRoot) (*dep.Manifest, *dep.Lock) { g.Logger.Println("Converting from GLOCKFILE ...") packages := make([]base.ImportedPackage, 0, len(g.packages)) for _, pkg := range g.packages { // Validate if pkg.importPath == "" { g.Logger.Println( " Warning: Skipping project. Invalid glock configuration, import path is required", ) continue } if pkg.revision == "" { // Do not add 'empty constraints' to the manifest. Solve will add to lock if required. g.Logger.Printf( " Warning: Skipping import with empty constraints. "+ "The solve step will add the dependency to the lock if needed: %q\n", pkg.importPath, ) continue } packages = append(packages, base.ImportedPackage{ Name: pkg.importPath, LockHint: pkg.revision, }) } g.ImportPackages(packages, true) return g.Manifest, g.Lock }
dep/internal/importers/glock/importer.go/0
{ "file_path": "dep/internal/importers/glock/importer.go", "repo_id": "dep", "token_count": 1302 }
37
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package gvt import ( "encoding/json" "io/ioutil" "log" "os" "path/filepath" "github.com/golang/dep" "github.com/golang/dep/gps" "github.com/golang/dep/internal/importers/base" "github.com/pkg/errors" ) const gvtPath = "vendor" + string(os.PathSeparator) + "manifest" // Importer imports gvt configuration into the dep configuration format. type Importer struct { *base.Importer gvtConfig gvtManifest } // NewImporter for gvt. It handles gb (gb-vendor) too as they share a common manifest file & format func NewImporter(logger *log.Logger, verbose bool, sm gps.SourceManager) *Importer { return &Importer{Importer: base.NewImporter(logger, verbose, sm)} } type gvtManifest struct { Deps []gvtPkg `json:"dependencies"` } type gvtPkg struct { ImportPath string Repository string Revision string Branch string } // Name of the importer. func (g *Importer) Name() string { return "gvt" } // HasDepMetadata checks if a directory contains config that the importer can handle. func (g *Importer) HasDepMetadata(dir string) bool { y := filepath.Join(dir, gvtPath) if _, err := os.Stat(y); err != nil { return false } return true } // Import the config found in the directory. func (g *Importer) Import(dir string, pr gps.ProjectRoot) (*dep.Manifest, *dep.Lock, error) { err := g.load(dir) if err != nil { return nil, nil, err } m, l := g.convert(pr) return m, l, nil } func (g *Importer) load(projectDir string) error { g.Logger.Println("Detected gb/gvt configuration files...") j := filepath.Join(projectDir, gvtPath) if g.Verbose { g.Logger.Printf(" Loading %s", j) } jb, err := ioutil.ReadFile(j) if err != nil { return errors.Wrapf(err, "unable to read %s", j) } err = json.Unmarshal(jb, &g.gvtConfig) if err != nil { return errors.Wrapf(err, "unable to parse %s", j) } return nil } func (g *Importer) convert(pr gps.ProjectRoot) (*dep.Manifest, *dep.Lock) { g.Logger.Println("Converting from vendor/manifest ...") packages := make([]base.ImportedPackage, 0, len(g.gvtConfig.Deps)) for _, pkg := range g.gvtConfig.Deps { // Validate if pkg.ImportPath == "" { g.Logger.Println( " Warning: Skipping project. Invalid gvt configuration, ImportPath is required", ) continue } if pkg.Revision == "" { g.Logger.Printf( " Warning: Invalid gvt configuration, Revision not found for ImportPath %q\n", pkg.ImportPath, ) } var contstraintHint = "" if pkg.Branch == "HEAD" { // gb-vendor sets "branch" to "HEAD", if the package was feteched via -tag or -revision, // we pass the revision as the constraint hint contstraintHint = pkg.Revision } else if pkg.Branch != "master" { // both gvt & gb-vendor set "branch" to "master" unless a different branch was requested. // so it's not really a constraint unless it's a different branch contstraintHint = pkg.Branch } ip := base.ImportedPackage{ Name: pkg.ImportPath, Source: pkg.Repository, LockHint: pkg.Revision, ConstraintHint: contstraintHint, } packages = append(packages, ip) } g.ImportPackages(packages, true) return g.Manifest, g.Lock }
dep/internal/importers/gvt/importer.go/0
{ "file_path": "dep/internal/importers/gvt/importer.go", "repo_id": "dep", "token_count": 1293 }
38
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package dep import ( "reflect" "strings" "testing" "github.com/golang/dep/gps" "github.com/golang/dep/gps/verify" "github.com/golang/dep/internal/test" ) func TestReadLock(t *testing.T) { h := test.NewHelper(t) defer h.Cleanup() golden := "lock/golden0.toml" g0f := h.GetTestFile(golden) defer g0f.Close() got, err := readLock(g0f) if err != nil { t.Fatalf("Should have read Lock correctly, but got err %q", err) } want := &Lock{ SolveMeta: SolveMeta{InputImports: []string{}}, P: []gps.LockedProject{ verify.VerifiableProject{ LockedProject: gps.NewLockedProject( gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep")}, gps.NewBranch("master").Pair(gps.Revision("d05d5aca9f895d19e9265839bffeadd74a2d2ecb")), []string{"."}, ), PruneOpts: gps.PruneOptions(1), Digest: verify.VersionedDigest{ HashVersion: verify.HashVersion, Digest: []byte("foo"), }, }, }, } if !reflect.DeepEqual(got, want) { t.Error("Valid lock did not parse as expected") } golden = "lock/golden1.toml" g1f := h.GetTestFile(golden) defer g1f.Close() got, err = readLock(g1f) if err != nil { t.Fatalf("Should have read Lock correctly, but got err %q", err) } want = &Lock{ SolveMeta: SolveMeta{InputImports: []string{}}, P: []gps.LockedProject{ verify.VerifiableProject{ LockedProject: gps.NewLockedProject( gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep")}, gps.NewVersion("0.12.2").Pair(gps.Revision("d05d5aca9f895d19e9265839bffeadd74a2d2ecb")), []string{"."}, ), PruneOpts: gps.PruneOptions(15), Digest: verify.VersionedDigest{ HashVersion: verify.HashVersion, Digest: []byte("foo"), }, }, }, } if !reflect.DeepEqual(got, want) { t.Error("Valid lock did not parse as expected") } } func TestWriteLock(t *testing.T) { h := test.NewHelper(t) defer h.Cleanup() golden := "lock/golden0.toml" want := h.GetTestFileString(golden) l := &Lock{ P: []gps.LockedProject{ verify.VerifiableProject{ LockedProject: gps.NewLockedProject( gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep")}, gps.NewBranch("master").Pair(gps.Revision("d05d5aca9f895d19e9265839bffeadd74a2d2ecb")), []string{"."}, ), PruneOpts: gps.PruneOptions(1), Digest: verify.VersionedDigest{ HashVersion: verify.HashVersion, Digest: []byte("foo"), }, }, }, } got, err := l.MarshalTOML() if err != nil { t.Fatalf("Error while marshaling valid lock to TOML: %q", err) } if string(got) != want { if *test.UpdateGolden { if err = h.WriteTestFile(golden, string(got)); err != nil { t.Fatal(err) } } else { t.Errorf("Valid lock did not marshal to TOML as expected:\n\t(GOT): %s\n\t(WNT): %s", string(got), want) } } golden = "lock/golden1.toml" want = h.GetTestFileString(golden) l = &Lock{ P: []gps.LockedProject{ verify.VerifiableProject{ LockedProject: gps.NewLockedProject( gps.ProjectIdentifier{ProjectRoot: gps.ProjectRoot("github.com/golang/dep")}, gps.NewVersion("0.12.2").Pair(gps.Revision("d05d5aca9f895d19e9265839bffeadd74a2d2ecb")), []string{"."}, ), PruneOpts: gps.PruneOptions(15), Digest: verify.VersionedDigest{ HashVersion: verify.HashVersion, Digest: []byte("foo"), }, }, }, } got, err = l.MarshalTOML() if err != nil { t.Fatalf("Error while marshaling valid lock to TOML: %q", err) } if string(got) != want { if *test.UpdateGolden { if err = h.WriteTestFile(golden, string(got)); err != nil { t.Fatal(err) } } else { t.Errorf("Valid lock did not marshal to TOML as expected:\n\t(GOT): %s\n\t(WNT): %s", string(got), want) } } } func TestReadLockErrors(t *testing.T) { h := test.NewHelper(t) defer h.Cleanup() var err error tests := []struct { name string file string }{ {"specified both", "lock/error0.toml"}, {"odd length", "lock/error1.toml"}, {"no branch or version", "lock/error2.toml"}, } for _, tst := range tests { lf := h.GetTestFile(tst.file) defer lf.Close() _, err = readLock(lf) if err == nil { t.Errorf("Reading lock with %s should have caused error, but did not", tst.name) } else if !strings.Contains(err.Error(), tst.name) { t.Errorf("Unexpected error %q; expected %s error", err, tst.name) } } }
dep/lock_test.go/0
{ "file_path": "dep/lock_test.go", "repo_id": "dep", "token_count": 2066 }
39
package semver import "strings" type unionConstraint []realConstraint func (uc unionConstraint) Matches(v Version) error { var uce MultiMatchFailure for _, c := range uc { err := c.Matches(v) if err == nil { return nil } uce = append(uce, err.(MatchFailure)) } return uce } func (uc unionConstraint) Intersect(c2 Constraint) Constraint { var other []realConstraint switch tc2 := c2.(type) { case none: return None() case any: return uc case Version: return c2 case rangeConstraint: other = append(other, tc2) case unionConstraint: other = c2.(unionConstraint) default: panic("unknown type") } var newc []Constraint // TODO there's a smarter way to do this than NxN, but...worth it? for _, c := range uc { for _, oc := range other { i := c.Intersect(oc) if !IsNone(i) { newc = append(newc, i) } } } return Union(newc...) } func (uc unionConstraint) MatchesAny(c Constraint) bool { for _, ic := range uc { if ic.MatchesAny(c) { return true } } return false } func (uc unionConstraint) Union(c Constraint) Constraint { return Union(uc, c) } func (uc unionConstraint) String() string { var pieces []string for _, c := range uc { pieces = append(pieces, c.String()) } return strings.Join(pieces, " || ") } func (uc unionConstraint) ImpliedCaretString() string { var pieces []string for _, c := range uc { pieces = append(pieces, c.ImpliedCaretString()) } return strings.Join(pieces, " || ") } func (unionConstraint) _private() {} type constraintList []realConstraint func (cl constraintList) Len() int { return len(cl) } func (cl constraintList) Swap(i, j int) { cl[i], cl[j] = cl[j], cl[i] } func (cl constraintList) Less(i, j int) bool { ic, jc := cl[i], cl[j] switch tic := ic.(type) { case Version: switch tjc := jc.(type) { case Version: return tic.LessThan(tjc) case rangeConstraint: if tjc.minIsZero() { return false } // Because we don't assume stable sort, always put versions ahead of // range mins if they're equal and includeMin is on if tjc.includeMin && tic.Equal(tjc.min) { return false } return tic.LessThan(tjc.min) } case rangeConstraint: switch tjc := jc.(type) { case Version: if tic.minIsZero() { return true } // Because we don't assume stable sort, always put versions ahead of // range mins if they're equal and includeMin is on if tic.includeMin && tjc.Equal(tic.min) { return false } return tic.min.LessThan(tjc) case rangeConstraint: if tic.minIsZero() { return true } if tjc.minIsZero() { return false } return tic.min.LessThan(tjc.min) } } panic("unreachable") } func (cl *constraintList) Push(x interface{}) { *cl = append(*cl, x.(realConstraint)) } func (cl *constraintList) Pop() interface{} { o := *cl c := o[len(o)-1] *cl = o[:len(o)-1] return c }
dep/vendor/github.com/Masterminds/semver/union.go/0
{ "file_path": "dep/vendor/github.com/Masterminds/semver/union.go", "repo_id": "dep", "token_count": 1201 }
40
package bolt import "unsafe" // maxMapSize represents the largest mmap size supported by Bolt. const maxMapSize = 0x7FFFFFFF // 2GB // maxAllocSize is the size used when creating array pointers. const maxAllocSize = 0xFFFFFFF // Are unaligned load/stores broken on this arch? var brokenUnaligned bool func init() { // Simple check to see whether this arch handles unaligned load/stores // correctly. // ARM9 and older devices require load/stores to be from/to aligned // addresses. If not, the lower 2 bits are cleared and that address is // read in a jumbled up order. // See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka15414.html raw := [6]byte{0xfe, 0xef, 0x11, 0x22, 0x22, 0x11} val := *(*uint32)(unsafe.Pointer(uintptr(unsafe.Pointer(&raw)) + 2)) brokenUnaligned = val != 0x11222211 }
dep/vendor/github.com/boltdb/bolt/bolt_arm.go/0
{ "file_path": "dep/vendor/github.com/boltdb/bolt/bolt_arm.go", "repo_id": "dep", "token_count": 277 }
41
package bolt import "errors" // These errors can be returned when opening or calling methods on a DB. var ( // ErrDatabaseNotOpen is returned when a DB instance is accessed before it // is opened or after it is closed. ErrDatabaseNotOpen = errors.New("database not open") // ErrDatabaseOpen is returned when opening a database that is // already open. ErrDatabaseOpen = errors.New("database already open") // ErrInvalid is returned when both meta pages on a database are invalid. // This typically occurs when a file is not a bolt database. ErrInvalid = errors.New("invalid database") // ErrVersionMismatch is returned when the data file was created with a // different version of Bolt. ErrVersionMismatch = errors.New("version mismatch") // ErrChecksum is returned when either meta page checksum does not match. ErrChecksum = errors.New("checksum error") // ErrTimeout is returned when a database cannot obtain an exclusive lock // on the data file after the timeout passed to Open(). ErrTimeout = errors.New("timeout") ) // These errors can occur when beginning or committing a Tx. var ( // ErrTxNotWritable is returned when performing a write operation on a // read-only transaction. ErrTxNotWritable = errors.New("tx not writable") // ErrTxClosed is returned when committing or rolling back a transaction // that has already been committed or rolled back. ErrTxClosed = errors.New("tx closed") // ErrDatabaseReadOnly is returned when a mutating transaction is started on a // read-only database. ErrDatabaseReadOnly = errors.New("database is in read-only mode") ) // These errors can occur when putting or deleting a value or a bucket. var ( // ErrBucketNotFound is returned when trying to access a bucket that has // not been created yet. ErrBucketNotFound = errors.New("bucket not found") // ErrBucketExists is returned when creating a bucket that already exists. ErrBucketExists = errors.New("bucket already exists") // ErrBucketNameRequired is returned when creating a bucket with a blank name. ErrBucketNameRequired = errors.New("bucket name required") // ErrKeyRequired is returned when inserting a zero-length key. ErrKeyRequired = errors.New("key required") // ErrKeyTooLarge is returned when inserting a key that is larger than MaxKeySize. ErrKeyTooLarge = errors.New("key too large") // ErrValueTooLarge is returned when inserting a value that is larger than MaxValueSize. ErrValueTooLarge = errors.New("value too large") // ErrIncompatibleValue is returned when trying create or delete a bucket // on an existing non-bucket key or when trying to create or delete a // non-bucket key on an existing bucket key. ErrIncompatibleValue = errors.New("incompatible value") )
dep/vendor/github.com/boltdb/bolt/errors.go/0
{ "file_path": "dep/vendor/github.com/boltdb/bolt/errors.go", "repo_id": "dep", "token_count": 734 }
42
// Go support for Protocol Buffers - Google's data interchange format // // Copyright 2012 The Go Authors. All rights reserved. // https://github.com/golang/protobuf // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following disclaimer // in the documentation and/or other materials provided with the // distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived from // this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // +build appengine js // This file contains an implementation of proto field accesses using package reflect. // It is slower than the code in pointer_unsafe.go but it avoids package unsafe and can // be used on App Engine. package proto import ( "math" "reflect" ) // A structPointer is a pointer to a struct. type structPointer struct { v reflect.Value } // toStructPointer returns a structPointer equivalent to the given reflect value. // The reflect value must itself be a pointer to a struct. func toStructPointer(v reflect.Value) structPointer { return structPointer{v} } // IsNil reports whether p is nil. func structPointer_IsNil(p structPointer) bool { return p.v.IsNil() } // Interface returns the struct pointer as an interface value. func structPointer_Interface(p structPointer, _ reflect.Type) interface{} { return p.v.Interface() } // A field identifies a field in a struct, accessible from a structPointer. // In this implementation, a field is identified by the sequence of field indices // passed to reflect's FieldByIndex. type field []int // toField returns a field equivalent to the given reflect field. func toField(f *reflect.StructField) field { return f.Index } // invalidField is an invalid field identifier. var invalidField = field(nil) // IsValid reports whether the field identifier is valid. func (f field) IsValid() bool { return f != nil } // field returns the given field in the struct as a reflect value. func structPointer_field(p structPointer, f field) reflect.Value { // Special case: an extension map entry with a value of type T // passes a *T to the struct-handling code with a zero field, // expecting that it will be treated as equivalent to *struct{ X T }, // which has the same memory layout. We have to handle that case // specially, because reflect will panic if we call FieldByIndex on a // non-struct. if f == nil { return p.v.Elem() } return p.v.Elem().FieldByIndex(f) } // ifield returns the given field in the struct as an interface value. func structPointer_ifield(p structPointer, f field) interface{} { return structPointer_field(p, f).Addr().Interface() } // Bytes returns the address of a []byte field in the struct. func structPointer_Bytes(p structPointer, f field) *[]byte { return structPointer_ifield(p, f).(*[]byte) } // BytesSlice returns the address of a [][]byte field in the struct. func structPointer_BytesSlice(p structPointer, f field) *[][]byte { return structPointer_ifield(p, f).(*[][]byte) } // Bool returns the address of a *bool field in the struct. func structPointer_Bool(p structPointer, f field) **bool { return structPointer_ifield(p, f).(**bool) } // BoolVal returns the address of a bool field in the struct. func structPointer_BoolVal(p structPointer, f field) *bool { return structPointer_ifield(p, f).(*bool) } // BoolSlice returns the address of a []bool field in the struct. func structPointer_BoolSlice(p structPointer, f field) *[]bool { return structPointer_ifield(p, f).(*[]bool) } // String returns the address of a *string field in the struct. func structPointer_String(p structPointer, f field) **string { return structPointer_ifield(p, f).(**string) } // StringVal returns the address of a string field in the struct. func structPointer_StringVal(p structPointer, f field) *string { return structPointer_ifield(p, f).(*string) } // StringSlice returns the address of a []string field in the struct. func structPointer_StringSlice(p structPointer, f field) *[]string { return structPointer_ifield(p, f).(*[]string) } // Extensions returns the address of an extension map field in the struct. func structPointer_Extensions(p structPointer, f field) *XXX_InternalExtensions { return structPointer_ifield(p, f).(*XXX_InternalExtensions) } // ExtMap returns the address of an extension map field in the struct. func structPointer_ExtMap(p structPointer, f field) *map[int32]Extension { return structPointer_ifield(p, f).(*map[int32]Extension) } // NewAt returns the reflect.Value for a pointer to a field in the struct. func structPointer_NewAt(p structPointer, f field, typ reflect.Type) reflect.Value { return structPointer_field(p, f).Addr() } // SetStructPointer writes a *struct field in the struct. func structPointer_SetStructPointer(p structPointer, f field, q structPointer) { structPointer_field(p, f).Set(q.v) } // GetStructPointer reads a *struct field in the struct. func structPointer_GetStructPointer(p structPointer, f field) structPointer { return structPointer{structPointer_field(p, f)} } // StructPointerSlice the address of a []*struct field in the struct. func structPointer_StructPointerSlice(p structPointer, f field) structPointerSlice { return structPointerSlice{structPointer_field(p, f)} } // A structPointerSlice represents the address of a slice of pointers to structs // (themselves messages or groups). That is, v.Type() is *[]*struct{...}. type structPointerSlice struct { v reflect.Value } func (p structPointerSlice) Len() int { return p.v.Len() } func (p structPointerSlice) Index(i int) structPointer { return structPointer{p.v.Index(i)} } func (p structPointerSlice) Append(q structPointer) { p.v.Set(reflect.Append(p.v, q.v)) } var ( int32Type = reflect.TypeOf(int32(0)) uint32Type = reflect.TypeOf(uint32(0)) float32Type = reflect.TypeOf(float32(0)) int64Type = reflect.TypeOf(int64(0)) uint64Type = reflect.TypeOf(uint64(0)) float64Type = reflect.TypeOf(float64(0)) ) // A word32 represents a field of type *int32, *uint32, *float32, or *enum. // That is, v.Type() is *int32, *uint32, *float32, or *enum and v is assignable. type word32 struct { v reflect.Value } // IsNil reports whether p is nil. func word32_IsNil(p word32) bool { return p.v.IsNil() } // Set sets p to point at a newly allocated word with bits set to x. func word32_Set(p word32, o *Buffer, x uint32) { t := p.v.Type().Elem() switch t { case int32Type: if len(o.int32s) == 0 { o.int32s = make([]int32, uint32PoolSize) } o.int32s[0] = int32(x) p.v.Set(reflect.ValueOf(&o.int32s[0])) o.int32s = o.int32s[1:] return case uint32Type: if len(o.uint32s) == 0 { o.uint32s = make([]uint32, uint32PoolSize) } o.uint32s[0] = x p.v.Set(reflect.ValueOf(&o.uint32s[0])) o.uint32s = o.uint32s[1:] return case float32Type: if len(o.float32s) == 0 { o.float32s = make([]float32, uint32PoolSize) } o.float32s[0] = math.Float32frombits(x) p.v.Set(reflect.ValueOf(&o.float32s[0])) o.float32s = o.float32s[1:] return } // must be enum p.v.Set(reflect.New(t)) p.v.Elem().SetInt(int64(int32(x))) } // Get gets the bits pointed at by p, as a uint32. func word32_Get(p word32) uint32 { elem := p.v.Elem() switch elem.Kind() { case reflect.Int32: return uint32(elem.Int()) case reflect.Uint32: return uint32(elem.Uint()) case reflect.Float32: return math.Float32bits(float32(elem.Float())) } panic("unreachable") } // Word32 returns a reference to a *int32, *uint32, *float32, or *enum field in the struct. func structPointer_Word32(p structPointer, f field) word32 { return word32{structPointer_field(p, f)} } // A word32Val represents a field of type int32, uint32, float32, or enum. // That is, v.Type() is int32, uint32, float32, or enum and v is assignable. type word32Val struct { v reflect.Value } // Set sets *p to x. func word32Val_Set(p word32Val, x uint32) { switch p.v.Type() { case int32Type: p.v.SetInt(int64(x)) return case uint32Type: p.v.SetUint(uint64(x)) return case float32Type: p.v.SetFloat(float64(math.Float32frombits(x))) return } // must be enum p.v.SetInt(int64(int32(x))) } // Get gets the bits pointed at by p, as a uint32. func word32Val_Get(p word32Val) uint32 { elem := p.v switch elem.Kind() { case reflect.Int32: return uint32(elem.Int()) case reflect.Uint32: return uint32(elem.Uint()) case reflect.Float32: return math.Float32bits(float32(elem.Float())) } panic("unreachable") } // Word32Val returns a reference to a int32, uint32, float32, or enum field in the struct. func structPointer_Word32Val(p structPointer, f field) word32Val { return word32Val{structPointer_field(p, f)} } // A word32Slice is a slice of 32-bit values. // That is, v.Type() is []int32, []uint32, []float32, or []enum. type word32Slice struct { v reflect.Value } func (p word32Slice) Append(x uint32) { n, m := p.v.Len(), p.v.Cap() if n < m { p.v.SetLen(n + 1) } else { t := p.v.Type().Elem() p.v.Set(reflect.Append(p.v, reflect.Zero(t))) } elem := p.v.Index(n) switch elem.Kind() { case reflect.Int32: elem.SetInt(int64(int32(x))) case reflect.Uint32: elem.SetUint(uint64(x)) case reflect.Float32: elem.SetFloat(float64(math.Float32frombits(x))) } } func (p word32Slice) Len() int { return p.v.Len() } func (p word32Slice) Index(i int) uint32 { elem := p.v.Index(i) switch elem.Kind() { case reflect.Int32: return uint32(elem.Int()) case reflect.Uint32: return uint32(elem.Uint()) case reflect.Float32: return math.Float32bits(float32(elem.Float())) } panic("unreachable") } // Word32Slice returns a reference to a []int32, []uint32, []float32, or []enum field in the struct. func structPointer_Word32Slice(p structPointer, f field) word32Slice { return word32Slice{structPointer_field(p, f)} } // word64 is like word32 but for 64-bit values. type word64 struct { v reflect.Value } func word64_Set(p word64, o *Buffer, x uint64) { t := p.v.Type().Elem() switch t { case int64Type: if len(o.int64s) == 0 { o.int64s = make([]int64, uint64PoolSize) } o.int64s[0] = int64(x) p.v.Set(reflect.ValueOf(&o.int64s[0])) o.int64s = o.int64s[1:] return case uint64Type: if len(o.uint64s) == 0 { o.uint64s = make([]uint64, uint64PoolSize) } o.uint64s[0] = x p.v.Set(reflect.ValueOf(&o.uint64s[0])) o.uint64s = o.uint64s[1:] return case float64Type: if len(o.float64s) == 0 { o.float64s = make([]float64, uint64PoolSize) } o.float64s[0] = math.Float64frombits(x) p.v.Set(reflect.ValueOf(&o.float64s[0])) o.float64s = o.float64s[1:] return } panic("unreachable") } func word64_IsNil(p word64) bool { return p.v.IsNil() } func word64_Get(p word64) uint64 { elem := p.v.Elem() switch elem.Kind() { case reflect.Int64: return uint64(elem.Int()) case reflect.Uint64: return elem.Uint() case reflect.Float64: return math.Float64bits(elem.Float()) } panic("unreachable") } func structPointer_Word64(p structPointer, f field) word64 { return word64{structPointer_field(p, f)} } // word64Val is like word32Val but for 64-bit values. type word64Val struct { v reflect.Value } func word64Val_Set(p word64Val, o *Buffer, x uint64) { switch p.v.Type() { case int64Type: p.v.SetInt(int64(x)) return case uint64Type: p.v.SetUint(x) return case float64Type: p.v.SetFloat(math.Float64frombits(x)) return } panic("unreachable") } func word64Val_Get(p word64Val) uint64 { elem := p.v switch elem.Kind() { case reflect.Int64: return uint64(elem.Int()) case reflect.Uint64: return elem.Uint() case reflect.Float64: return math.Float64bits(elem.Float()) } panic("unreachable") } func structPointer_Word64Val(p structPointer, f field) word64Val { return word64Val{structPointer_field(p, f)} } type word64Slice struct { v reflect.Value } func (p word64Slice) Append(x uint64) { n, m := p.v.Len(), p.v.Cap() if n < m { p.v.SetLen(n + 1) } else { t := p.v.Type().Elem() p.v.Set(reflect.Append(p.v, reflect.Zero(t))) } elem := p.v.Index(n) switch elem.Kind() { case reflect.Int64: elem.SetInt(int64(int64(x))) case reflect.Uint64: elem.SetUint(uint64(x)) case reflect.Float64: elem.SetFloat(float64(math.Float64frombits(x))) } } func (p word64Slice) Len() int { return p.v.Len() } func (p word64Slice) Index(i int) uint64 { elem := p.v.Index(i) switch elem.Kind() { case reflect.Int64: return uint64(elem.Int()) case reflect.Uint64: return uint64(elem.Uint()) case reflect.Float64: return math.Float64bits(float64(elem.Float())) } panic("unreachable") } func structPointer_Word64Slice(p structPointer, f field) word64Slice { return word64Slice{structPointer_field(p, f)} }
dep/vendor/github.com/golang/protobuf/proto/pointer_reflect.go/0
{ "file_path": "dep/vendor/github.com/golang/protobuf/proto/pointer_reflect.go", "repo_id": "dep", "token_count": 5164 }
43
// Copyright 2017, The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE.md file. // +build purego appengine js package cmp import "reflect" const supportAllowUnexported = false func unsafeRetrieveField(reflect.Value, reflect.StructField) reflect.Value { panic("unsafeRetrieveField is not implemented") }
dep/vendor/github.com/google/go-cmp/cmp/unsafe_panic.go/0
{ "file_path": "dep/vendor/github.com/google/go-cmp/cmp/unsafe_panic.go", "repo_id": "dep", "token_count": 110 }
44
package toml import ( "bytes" "errors" "fmt" "io" "reflect" "strconv" "strings" "time" ) const tagKeyMultiline = "multiline" type tomlOpts struct { name string comment string commented bool multiline bool include bool omitempty bool } type encOpts struct { quoteMapKeys bool arraysOneElementPerLine bool } var encOptsDefaults = encOpts{ quoteMapKeys: false, } var timeType = reflect.TypeOf(time.Time{}) var marshalerType = reflect.TypeOf(new(Marshaler)).Elem() // Check if the given marshall type maps to a Tree primitive func isPrimitive(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Ptr: return isPrimitive(mtype.Elem()) case reflect.Bool: return true case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return true case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return true case reflect.Float32, reflect.Float64: return true case reflect.String: return true case reflect.Struct: return mtype == timeType || isCustomMarshaler(mtype) default: return false } } // Check if the given marshall type maps to a Tree slice func isTreeSlice(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Slice: return !isOtherSlice(mtype) default: return false } } // Check if the given marshall type maps to a non-Tree slice func isOtherSlice(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Ptr: return isOtherSlice(mtype.Elem()) case reflect.Slice: return isPrimitive(mtype.Elem()) || isOtherSlice(mtype.Elem()) default: return false } } // Check if the given marshall type maps to a Tree func isTree(mtype reflect.Type) bool { switch mtype.Kind() { case reflect.Map: return true case reflect.Struct: return !isPrimitive(mtype) default: return false } } func isCustomMarshaler(mtype reflect.Type) bool { return mtype.Implements(marshalerType) } func callCustomMarshaler(mval reflect.Value) ([]byte, error) { return mval.Interface().(Marshaler).MarshalTOML() } // Marshaler is the interface implemented by types that // can marshal themselves into valid TOML. type Marshaler interface { MarshalTOML() ([]byte, error) } /* Marshal returns the TOML encoding of v. Behavior is similar to the Go json encoder, except that there is no concept of a Marshaler interface or MarshalTOML function for sub-structs, and currently only definite types can be marshaled (i.e. no `interface{}`). The following struct annotations are supported: toml:"Field" Overrides the field's name to output. omitempty When set, empty values and groups are not emitted. comment:"comment" Emits a # comment on the same line. This supports new lines. commented:"true" Emits the value as commented. Note that pointers are automatically assigned the "omitempty" option, as TOML explicitly does not handle null values (saying instead the label should be dropped). Tree structural types and corresponding marshal types: *Tree (*)struct, (*)map[string]interface{} []*Tree (*)[](*)struct, (*)[](*)map[string]interface{} []interface{} (as interface{}) (*)[]primitive, (*)[]([]interface{}) interface{} (*)primitive Tree primitive types and corresponding marshal types: uint64 uint, uint8-uint64, pointers to same int64 int, int8-uint64, pointers to same float64 float32, float64, pointers to same string string, pointers to same bool bool, pointers to same time.Time time.Time{}, pointers to same */ func Marshal(v interface{}) ([]byte, error) { return NewEncoder(nil).marshal(v) } // Encoder writes TOML values to an output stream. type Encoder struct { w io.Writer encOpts } // NewEncoder returns a new encoder that writes to w. func NewEncoder(w io.Writer) *Encoder { return &Encoder{ w: w, encOpts: encOptsDefaults, } } // Encode writes the TOML encoding of v to the stream. // // See the documentation for Marshal for details. func (e *Encoder) Encode(v interface{}) error { b, err := e.marshal(v) if err != nil { return err } if _, err := e.w.Write(b); err != nil { return err } return nil } // QuoteMapKeys sets up the encoder to encode // maps with string type keys with quoted TOML keys. // // This relieves the character limitations on map keys. func (e *Encoder) QuoteMapKeys(v bool) *Encoder { e.quoteMapKeys = v return e } // ArraysWithOneElementPerLine sets up the encoder to encode arrays // with more than one element on multiple lines instead of one. // // For example: // // A = [1,2,3] // // Becomes // // A = [ // 1, // 2, // 3, // ] func (e *Encoder) ArraysWithOneElementPerLine(v bool) *Encoder { e.arraysOneElementPerLine = v return e } func (e *Encoder) marshal(v interface{}) ([]byte, error) { mtype := reflect.TypeOf(v) if mtype.Kind() != reflect.Struct { return []byte{}, errors.New("Only a struct can be marshaled to TOML") } sval := reflect.ValueOf(v) if isCustomMarshaler(mtype) { return callCustomMarshaler(sval) } t, err := e.valueToTree(mtype, sval) if err != nil { return []byte{}, err } var buf bytes.Buffer _, err = t.writeTo(&buf, "", "", 0, e.arraysOneElementPerLine) return buf.Bytes(), err } // Convert given marshal struct or map value to toml tree func (e *Encoder) valueToTree(mtype reflect.Type, mval reflect.Value) (*Tree, error) { if mtype.Kind() == reflect.Ptr { return e.valueToTree(mtype.Elem(), mval.Elem()) } tval := newTree() switch mtype.Kind() { case reflect.Struct: for i := 0; i < mtype.NumField(); i++ { mtypef, mvalf := mtype.Field(i), mval.Field(i) opts := tomlOptions(mtypef) if opts.include && (!opts.omitempty || !isZero(mvalf)) { val, err := e.valueToToml(mtypef.Type, mvalf) if err != nil { return nil, err } tval.SetWithOptions(opts.name, SetOptions{ Comment: opts.comment, Commented: opts.commented, Multiline: opts.multiline, }, val) } } case reflect.Map: for _, key := range mval.MapKeys() { mvalf := mval.MapIndex(key) val, err := e.valueToToml(mtype.Elem(), mvalf) if err != nil { return nil, err } if e.quoteMapKeys { keyStr, err := tomlValueStringRepresentation(key.String(), "", e.arraysOneElementPerLine) if err != nil { return nil, err } tval.SetPath([]string{keyStr}, val) } else { tval.Set(key.String(), val) } } } return tval, nil } // Convert given marshal slice to slice of Toml trees func (e *Encoder) valueToTreeSlice(mtype reflect.Type, mval reflect.Value) ([]*Tree, error) { tval := make([]*Tree, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { val, err := e.valueToTree(mtype.Elem(), mval.Index(i)) if err != nil { return nil, err } tval[i] = val } return tval, nil } // Convert given marshal slice to slice of toml values func (e *Encoder) valueToOtherSlice(mtype reflect.Type, mval reflect.Value) (interface{}, error) { tval := make([]interface{}, mval.Len(), mval.Len()) for i := 0; i < mval.Len(); i++ { val, err := e.valueToToml(mtype.Elem(), mval.Index(i)) if err != nil { return nil, err } tval[i] = val } return tval, nil } // Convert given marshal value to toml value func (e *Encoder) valueToToml(mtype reflect.Type, mval reflect.Value) (interface{}, error) { if mtype.Kind() == reflect.Ptr { return e.valueToToml(mtype.Elem(), mval.Elem()) } switch { case isCustomMarshaler(mtype): return callCustomMarshaler(mval) case isTree(mtype): return e.valueToTree(mtype, mval) case isTreeSlice(mtype): return e.valueToTreeSlice(mtype, mval) case isOtherSlice(mtype): return e.valueToOtherSlice(mtype, mval) default: switch mtype.Kind() { case reflect.Bool: return mval.Bool(), nil case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return mval.Int(), nil case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return mval.Uint(), nil case reflect.Float32, reflect.Float64: return mval.Float(), nil case reflect.String: return mval.String(), nil case reflect.Struct: return mval.Interface().(time.Time), nil default: return nil, fmt.Errorf("Marshal can't handle %v(%v)", mtype, mtype.Kind()) } } } // Unmarshal attempts to unmarshal the Tree into a Go struct pointed by v. // Neither Unmarshaler interfaces nor UnmarshalTOML functions are supported for // sub-structs, and only definite types can be unmarshaled. func (t *Tree) Unmarshal(v interface{}) error { d := Decoder{tval: t} return d.unmarshal(v) } // Marshal returns the TOML encoding of Tree. // See Marshal() documentation for types mapping table. func (t *Tree) Marshal() ([]byte, error) { var buf bytes.Buffer err := NewEncoder(&buf).Encode(t) return buf.Bytes(), err } // Unmarshal parses the TOML-encoded data and stores the result in the value // pointed to by v. Behavior is similar to the Go json encoder, except that there // is no concept of an Unmarshaler interface or UnmarshalTOML function for // sub-structs, and currently only definite types can be unmarshaled to (i.e. no // `interface{}`). // // The following struct annotations are supported: // // toml:"Field" Overrides the field's name to map to. // // See Marshal() documentation for types mapping table. func Unmarshal(data []byte, v interface{}) error { t, err := LoadReader(bytes.NewReader(data)) if err != nil { return err } return t.Unmarshal(v) } // Decoder reads and decodes TOML values from an input stream. type Decoder struct { r io.Reader tval *Tree encOpts } // NewDecoder returns a new decoder that reads from r. func NewDecoder(r io.Reader) *Decoder { return &Decoder{ r: r, encOpts: encOptsDefaults, } } // Decode reads a TOML-encoded value from it's input // and unmarshals it in the value pointed at by v. // // See the documentation for Marshal for details. func (d *Decoder) Decode(v interface{}) error { var err error d.tval, err = LoadReader(d.r) if err != nil { return err } return d.unmarshal(v) } func (d *Decoder) unmarshal(v interface{}) error { mtype := reflect.TypeOf(v) if mtype.Kind() != reflect.Ptr || mtype.Elem().Kind() != reflect.Struct { return errors.New("Only a pointer to struct can be unmarshaled from TOML") } sval, err := d.valueFromTree(mtype.Elem(), d.tval) if err != nil { return err } reflect.ValueOf(v).Elem().Set(sval) return nil } // Convert toml tree to marshal struct or map, using marshal type func (d *Decoder) valueFromTree(mtype reflect.Type, tval *Tree) (reflect.Value, error) { if mtype.Kind() == reflect.Ptr { return d.unwrapPointer(mtype, tval) } var mval reflect.Value switch mtype.Kind() { case reflect.Struct: mval = reflect.New(mtype).Elem() for i := 0; i < mtype.NumField(); i++ { mtypef := mtype.Field(i) opts := tomlOptions(mtypef) if opts.include { baseKey := opts.name keysToTry := []string{baseKey, strings.ToLower(baseKey), strings.ToTitle(baseKey)} for _, key := range keysToTry { exists := tval.Has(key) if !exists { continue } val := tval.Get(key) mvalf, err := d.valueFromToml(mtypef.Type, val) if err != nil { return mval, formatError(err, tval.GetPosition(key)) } mval.Field(i).Set(mvalf) break } } } case reflect.Map: mval = reflect.MakeMap(mtype) for _, key := range tval.Keys() { // TODO: path splits key val := tval.GetPath([]string{key}) mvalf, err := d.valueFromToml(mtype.Elem(), val) if err != nil { return mval, formatError(err, tval.GetPosition(key)) } mval.SetMapIndex(reflect.ValueOf(key), mvalf) } } return mval, nil } // Convert toml value to marshal struct/map slice, using marshal type func (d *Decoder) valueFromTreeSlice(mtype reflect.Type, tval []*Tree) (reflect.Value, error) { mval := reflect.MakeSlice(mtype, len(tval), len(tval)) for i := 0; i < len(tval); i++ { val, err := d.valueFromTree(mtype.Elem(), tval[i]) if err != nil { return mval, err } mval.Index(i).Set(val) } return mval, nil } // Convert toml value to marshal primitive slice, using marshal type func (d *Decoder) valueFromOtherSlice(mtype reflect.Type, tval []interface{}) (reflect.Value, error) { mval := reflect.MakeSlice(mtype, len(tval), len(tval)) for i := 0; i < len(tval); i++ { val, err := d.valueFromToml(mtype.Elem(), tval[i]) if err != nil { return mval, err } mval.Index(i).Set(val) } return mval, nil } // Convert toml value to marshal value, using marshal type func (d *Decoder) valueFromToml(mtype reflect.Type, tval interface{}) (reflect.Value, error) { if mtype.Kind() == reflect.Ptr { return d.unwrapPointer(mtype, tval) } switch tval.(type) { case *Tree: if isTree(mtype) { return d.valueFromTree(mtype, tval.(*Tree)) } return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a tree", tval, tval) case []*Tree: if isTreeSlice(mtype) { return d.valueFromTreeSlice(mtype, tval.([]*Tree)) } return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to trees", tval, tval) case []interface{}: if isOtherSlice(mtype) { return d.valueFromOtherSlice(mtype, tval.([]interface{})) } return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to a slice", tval, tval) default: switch mtype.Kind() { case reflect.Bool, reflect.Struct: val := reflect.ValueOf(tval) // if this passes for when mtype is reflect.Struct, tval is a time.Time if !val.Type().ConvertibleTo(mtype) { return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } return val.Convert(mtype), nil case reflect.String: val := reflect.ValueOf(tval) // stupidly, int64 is convertible to string. So special case this. if !val.Type().ConvertibleTo(mtype) || val.Kind() == reflect.Int64 { return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } return val.Convert(mtype), nil case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: val := reflect.ValueOf(tval) if !val.Type().ConvertibleTo(mtype) { return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } if reflect.Indirect(reflect.New(mtype)).OverflowInt(val.Int()) { return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String()) } return val.Convert(mtype), nil case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: val := reflect.ValueOf(tval) if !val.Type().ConvertibleTo(mtype) { return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } if val.Int() < 0 { return reflect.ValueOf(nil), fmt.Errorf("%v(%T) is negative so does not fit in %v", tval, tval, mtype.String()) } if reflect.Indirect(reflect.New(mtype)).OverflowUint(uint64(val.Int())) { return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String()) } return val.Convert(mtype), nil case reflect.Float32, reflect.Float64: val := reflect.ValueOf(tval) if !val.Type().ConvertibleTo(mtype) { return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v", tval, tval, mtype.String()) } if reflect.Indirect(reflect.New(mtype)).OverflowFloat(val.Float()) { return reflect.ValueOf(nil), fmt.Errorf("%v(%T) would overflow %v", tval, tval, mtype.String()) } return val.Convert(mtype), nil default: return reflect.ValueOf(nil), fmt.Errorf("Can't convert %v(%T) to %v(%v)", tval, tval, mtype, mtype.Kind()) } } } func (d *Decoder) unwrapPointer(mtype reflect.Type, tval interface{}) (reflect.Value, error) { val, err := d.valueFromToml(mtype.Elem(), tval) if err != nil { return reflect.ValueOf(nil), err } mval := reflect.New(mtype.Elem()) mval.Elem().Set(val) return mval, nil } func tomlOptions(vf reflect.StructField) tomlOpts { tag := vf.Tag.Get("toml") parse := strings.Split(tag, ",") var comment string if c := vf.Tag.Get("comment"); c != "" { comment = c } commented, _ := strconv.ParseBool(vf.Tag.Get("commented")) multiline, _ := strconv.ParseBool(vf.Tag.Get(tagKeyMultiline)) result := tomlOpts{name: vf.Name, comment: comment, commented: commented, multiline: multiline, include: true, omitempty: false} if parse[0] != "" { if parse[0] == "-" && len(parse) == 1 { result.include = false } else { result.name = strings.Trim(parse[0], " ") } } if vf.PkgPath != "" { result.include = false } if len(parse) > 1 && strings.Trim(parse[1], " ") == "omitempty" { result.omitempty = true } if vf.Type.Kind() == reflect.Ptr { result.omitempty = true } return result } func isZero(val reflect.Value) bool { switch val.Type().Kind() { case reflect.Map: fallthrough case reflect.Array: fallthrough case reflect.Slice: return val.Len() == 0 default: return reflect.DeepEqual(val.Interface(), reflect.Zero(val.Type()).Interface()) } } func formatError(err error, pos Position) error { if err.Error()[0] == '(' { // Error already contains position information return err } return fmt.Errorf("%s: %s", pos, err) }
dep/vendor/github.com/pelletier/go-toml/marshal.go/0
{ "file_path": "dep/vendor/github.com/pelletier/go-toml/marshal.go", "repo_id": "dep", "token_count": 6773 }
45
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package context defines the Context type, which carries deadlines, // cancelation signals, and other request-scoped values across API boundaries // and between processes. // // Incoming requests to a server should create a Context, and outgoing calls to // servers should accept a Context. The chain of function calls between must // propagate the Context, optionally replacing it with a modified copy created // using WithDeadline, WithTimeout, WithCancel, or WithValue. // // Programs that use Contexts should follow these rules to keep interfaces // consistent across packages and enable static analysis tools to check context // propagation: // // Do not store Contexts inside a struct type; instead, pass a Context // explicitly to each function that needs it. The Context should be the first // parameter, typically named ctx: // // func DoSomething(ctx context.Context, arg Arg) error { // // ... use ctx ... // } // // Do not pass a nil Context, even if a function permits it. Pass context.TODO // if you are unsure about which Context to use. // // Use context Values only for request-scoped data that transits processes and // APIs, not for passing optional parameters to functions. // // The same Context may be passed to functions running in different goroutines; // Contexts are safe for simultaneous use by multiple goroutines. // // See http://blog.golang.org/context for example code for a server that uses // Contexts. package context // import "golang.org/x/net/context" // Background returns a non-nil, empty Context. It is never canceled, has no // values, and has no deadline. It is typically used by the main function, // initialization, and tests, and as the top-level Context for incoming // requests. func Background() Context { return background } // TODO returns a non-nil, empty Context. Code should use context.TODO when // it's unclear which Context to use or it is not yet available (because the // surrounding function has not yet been extended to accept a Context // parameter). TODO is recognized by static analysis tools that determine // whether Contexts are propagated correctly in a program. func TODO() Context { return todo }
dep/vendor/golang.org/x/net/context/context.go/0
{ "file_path": "dep/vendor/golang.org/x/net/context/context.go", "repo_id": "dep", "token_count": 569 }
46
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // +build darwin dragonfly freebsd netbsd openbsd // BSD system call wrappers shared by *BSD based systems // including OS X (Darwin) and FreeBSD. Like the other // syscall_*.go files it is compiled as Go code but also // used as input to mksyscall which parses the //sys // lines and generates system call stubs. package unix import ( "runtime" "syscall" "unsafe" ) /* * Wrapped */ //sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error) //sysnb setgroups(ngid int, gid *_Gid_t) (err error) func Getgroups() (gids []int, err error) { n, err := getgroups(0, nil) if err != nil { return nil, err } if n == 0 { return nil, nil } // Sanity check group count. Max is 16 on BSD. if n < 0 || n > 1000 { return nil, EINVAL } a := make([]_Gid_t, n) n, err = getgroups(n, &a[0]) if err != nil { return nil, err } gids = make([]int, n) for i, v := range a[0:n] { gids[i] = int(v) } return } func Setgroups(gids []int) (err error) { if len(gids) == 0 { return setgroups(0, nil) } a := make([]_Gid_t, len(gids)) for i, v := range gids { a[i] = _Gid_t(v) } return setgroups(len(a), &a[0]) } func ReadDirent(fd int, buf []byte) (n int, err error) { // Final argument is (basep *uintptr) and the syscall doesn't take nil. // 64 bits should be enough. (32 bits isn't even on 386). Since the // actual system call is getdirentries64, 64 is a good guess. // TODO(rsc): Can we use a single global basep for all calls? var base = (*uintptr)(unsafe.Pointer(new(uint64))) return Getdirentries(fd, buf, base) } // Wait status is 7 bits at bottom, either 0 (exited), // 0x7F (stopped), or a signal number that caused an exit. // The 0x80 bit is whether there was a core dump. // An extra number (exit code, signal causing a stop) // is in the high bits. type WaitStatus uint32 const ( mask = 0x7F core = 0x80 shift = 8 exited = 0 stopped = 0x7F ) func (w WaitStatus) Exited() bool { return w&mask == exited } func (w WaitStatus) ExitStatus() int { if w&mask != exited { return -1 } return int(w >> shift) } func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 } func (w WaitStatus) Signal() syscall.Signal { sig := syscall.Signal(w & mask) if sig == stopped || sig == 0 { return -1 } return sig } func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 } func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP } func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP } func (w WaitStatus) StopSignal() syscall.Signal { if !w.Stopped() { return -1 } return syscall.Signal(w>>shift) & 0xFF } func (w WaitStatus) TrapCause() int { return -1 } //sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error) func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { var status _C_int wpid, err = wait4(pid, &status, options, rusage) if wstatus != nil { *wstatus = WaitStatus(status) } return } //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) //sysnb socket(domain int, typ int, proto int) (fd int, err error) //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) //sys Shutdown(s int, how int) (err error) func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Port < 0 || sa.Port > 0xFFFF { return nil, 0, EINVAL } sa.raw.Len = SizeofSockaddrInet4 sa.raw.Family = AF_INET p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) for i := 0; i < len(sa.Addr); i++ { sa.raw.Addr[i] = sa.Addr[i] } return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Port < 0 || sa.Port > 0xFFFF { return nil, 0, EINVAL } sa.raw.Len = SizeofSockaddrInet6 sa.raw.Family = AF_INET6 p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId for i := 0; i < len(sa.Addr); i++ { sa.raw.Addr[i] = sa.Addr[i] } return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { name := sa.Name n := len(name) if n >= len(sa.raw.Path) || n == 0 { return nil, 0, EINVAL } sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL sa.raw.Family = AF_UNIX for i := 0; i < n; i++ { sa.raw.Path[i] = int8(name[i]) } return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil } func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Index == 0 { return nil, 0, EINVAL } sa.raw.Len = sa.Len sa.raw.Family = AF_LINK sa.raw.Index = sa.Index sa.raw.Type = sa.Type sa.raw.Nlen = sa.Nlen sa.raw.Alen = sa.Alen sa.raw.Slen = sa.Slen for i := 0; i < len(sa.raw.Data); i++ { sa.raw.Data[i] = sa.Data[i] } return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil } func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { switch rsa.Addr.Family { case AF_LINK: pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa)) sa := new(SockaddrDatalink) sa.Len = pp.Len sa.Family = pp.Family sa.Index = pp.Index sa.Type = pp.Type sa.Nlen = pp.Nlen sa.Alen = pp.Alen sa.Slen = pp.Slen for i := 0; i < len(sa.Data); i++ { sa.Data[i] = pp.Data[i] } return sa, nil case AF_UNIX: pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) if pp.Len < 2 || pp.Len > SizeofSockaddrUnix { return nil, EINVAL } sa := new(SockaddrUnix) // Some BSDs include the trailing NUL in the length, whereas // others do not. Work around this by subtracting the leading // family and len. The path is then scanned to see if a NUL // terminator still exists within the length. n := int(pp.Len) - 2 // subtract leading Family, Len for i := 0; i < n; i++ { if pp.Path[i] == 0 { // found early NUL; assume Len included the NUL // or was overestimating. n = i break } } bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] sa.Name = string(bytes) return sa, nil case AF_INET: pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) for i := 0; i < len(sa.Addr); i++ { sa.Addr[i] = pp.Addr[i] } return sa, nil case AF_INET6: pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) sa := new(SockaddrInet6) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id for i := 0; i < len(sa.Addr); i++ { sa.Addr[i] = pp.Addr[i] } return sa, nil } return nil, EAFNOSUPPORT } func Accept(fd int) (nfd int, sa Sockaddr, err error) { var rsa RawSockaddrAny var len _Socklen = SizeofSockaddrAny nfd, err = accept(fd, &rsa, &len) if err != nil { return } if runtime.GOOS == "darwin" && len == 0 { // Accepted socket has no address. // This is likely due to a bug in xnu kernels, // where instead of ECONNABORTED error socket // is accepted, but has no address. Close(nfd) return 0, nil, ECONNABORTED } sa, err = anyToSockaddr(&rsa) if err != nil { Close(nfd) nfd = 0 } return } func Getsockname(fd int) (sa Sockaddr, err error) { var rsa RawSockaddrAny var len _Socklen = SizeofSockaddrAny if err = getsockname(fd, &rsa, &len); err != nil { return } // TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be // reported upstream. if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 { rsa.Addr.Family = AF_UNIX rsa.Addr.Len = SizeofSockaddrUnix } return anyToSockaddr(&rsa) } //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) func GetsockoptByte(fd, level, opt int) (value byte, err error) { var n byte vallen := _Socklen(1) err = getsockopt(fd, level, opt, unsafe.Pointer(&n), &vallen) return n, err } func GetsockoptInet4Addr(fd, level, opt int) (value [4]byte, err error) { vallen := _Socklen(4) err = getsockopt(fd, level, opt, unsafe.Pointer(&value[0]), &vallen) return value, err } func GetsockoptIPMreq(fd, level, opt int) (*IPMreq, error) { var value IPMreq vallen := _Socklen(SizeofIPMreq) err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) return &value, err } func GetsockoptIPv6Mreq(fd, level, opt int) (*IPv6Mreq, error) { var value IPv6Mreq vallen := _Socklen(SizeofIPv6Mreq) err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) return &value, err } func GetsockoptIPv6MTUInfo(fd, level, opt int) (*IPv6MTUInfo, error) { var value IPv6MTUInfo vallen := _Socklen(SizeofIPv6MTUInfo) err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) return &value, err } func GetsockoptICMPv6Filter(fd, level, opt int) (*ICMPv6Filter, error) { var value ICMPv6Filter vallen := _Socklen(SizeofICMPv6Filter) err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) return &value, err } //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { var msg Msghdr var rsa RawSockaddrAny msg.Name = (*byte)(unsafe.Pointer(&rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { iov.Base = (*byte)(unsafe.Pointer(&p[0])) iov.SetLen(len(p)) } var dummy byte if len(oob) > 0 { // receive at least one normal byte if len(p) == 0 { iov.Base = &dummy iov.SetLen(1) } msg.Control = (*byte)(unsafe.Pointer(&oob[0])) msg.SetControllen(len(oob)) } msg.Iov = &iov msg.Iovlen = 1 if n, err = recvmsg(fd, &msg, flags); err != nil { return } oobn = int(msg.Controllen) recvflags = int(msg.Flags) // source address is only specified if the socket is unconnected if rsa.Addr.Family != AF_UNSPEC { from, err = anyToSockaddr(&rsa) } return } //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { _, err = SendmsgN(fd, p, oob, to, flags) return } func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { var ptr unsafe.Pointer var salen _Socklen if to != nil { ptr, salen, err = to.sockaddr() if err != nil { return 0, err } } var msg Msghdr msg.Name = (*byte)(unsafe.Pointer(ptr)) msg.Namelen = uint32(salen) var iov Iovec if len(p) > 0 { iov.Base = (*byte)(unsafe.Pointer(&p[0])) iov.SetLen(len(p)) } var dummy byte if len(oob) > 0 { // send at least one normal byte if len(p) == 0 { iov.Base = &dummy iov.SetLen(1) } msg.Control = (*byte)(unsafe.Pointer(&oob[0])) msg.SetControllen(len(oob)) } msg.Iov = &iov msg.Iovlen = 1 if n, err = sendmsg(fd, &msg, flags); err != nil { return 0, err } if len(oob) > 0 && len(p) == 0 { n = 0 } return n, nil } //sys kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error) func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) { var change, event unsafe.Pointer if len(changes) > 0 { change = unsafe.Pointer(&changes[0]) } if len(events) > 0 { event = unsafe.Pointer(&events[0]) } return kevent(kq, change, len(changes), event, len(events), timeout) } //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL // sysctlmib translates name to mib number and appends any additional args. func sysctlmib(name string, args ...int) ([]_C_int, error) { // Translate name to mib number. mib, err := nametomib(name) if err != nil { return nil, err } for _, a := range args { mib = append(mib, _C_int(a)) } return mib, nil } func Sysctl(name string) (string, error) { return SysctlArgs(name) } func SysctlArgs(name string, args ...int) (string, error) { buf, err := SysctlRaw(name, args...) if err != nil { return "", err } n := len(buf) // Throw away terminating NUL. if n > 0 && buf[n-1] == '\x00' { n-- } return string(buf[0:n]), nil } func SysctlUint32(name string) (uint32, error) { return SysctlUint32Args(name) } func SysctlUint32Args(name string, args ...int) (uint32, error) { mib, err := sysctlmib(name, args...) if err != nil { return 0, err } n := uintptr(4) buf := make([]byte, 4) if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { return 0, err } if n != 4 { return 0, EIO } return *(*uint32)(unsafe.Pointer(&buf[0])), nil } func SysctlUint64(name string, args ...int) (uint64, error) { mib, err := sysctlmib(name, args...) if err != nil { return 0, err } n := uintptr(8) buf := make([]byte, 8) if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { return 0, err } if n != 8 { return 0, EIO } return *(*uint64)(unsafe.Pointer(&buf[0])), nil } func SysctlRaw(name string, args ...int) ([]byte, error) { mib, err := sysctlmib(name, args...) if err != nil { return nil, err } // Find size. n := uintptr(0) if err := sysctl(mib, nil, &n, nil, 0); err != nil { return nil, err } if n == 0 { return nil, nil } // Read into buffer of that size. buf := make([]byte, n) if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil { return nil, err } // The actual call may return less than the original reported required // size so ensure we deal with that. return buf[:n], nil } //sys utimes(path string, timeval *[2]Timeval) (err error) func Utimes(path string, tv []Timeval) error { if tv == nil { return utimes(path, nil) } if len(tv) != 2 { return EINVAL } return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } func UtimesNano(path string, ts []Timespec) error { if ts == nil { err := utimensat(AT_FDCWD, path, nil, 0) if err != ENOSYS { return err } return utimes(path, nil) } if len(ts) != 2 { return EINVAL } err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) if err != ENOSYS { return err } // Not as efficient as it could be because Timespec and // Timeval have different types in the different OSes tv := [2]Timeval{ NsecToTimeval(TimespecToNsec(ts[0])), NsecToTimeval(TimespecToNsec(ts[1])), } return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { if ts == nil { return utimensat(dirfd, path, nil, flags) } if len(ts) != 2 { return EINVAL } return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) } //sys futimes(fd int, timeval *[2]Timeval) (err error) func Futimes(fd int, tv []Timeval) error { if tv == nil { return futimes(fd, nil) } if len(tv) != 2 { return EINVAL } return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } //sys fcntl(fd int, cmd int, arg int) (val int, err error) // TODO: wrap // Acct(name nil-string) (err error) // Gethostuuid(uuid *byte, timeout *Timespec) (err error) // Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error) var mapper = &mmapper{ active: make(map[*byte][]byte), mmap: mmap, munmap: munmap, } func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { return mapper.Mmap(fd, offset, length, prot, flags) } func Munmap(b []byte) (err error) { return mapper.Munmap(b) } //sys Madvise(b []byte, behav int) (err error) //sys Mlock(b []byte) (err error) //sys Mlockall(flags int) (err error) //sys Mprotect(b []byte, prot int) (err error) //sys Msync(b []byte, flags int) (err error) //sys Munlock(b []byte) (err error) //sys Munlockall() (err error)
dep/vendor/golang.org/x/sys/unix/syscall_bsd.go/0
{ "file_path": "dep/vendor/golang.org/x/sys/unix/syscall_bsd.go", "repo_id": "dep", "token_count": 6968 }
47
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Solaris system calls. // This file is compiled as ordinary Go code, // but it is also input to mksyscall, // which parses the //sys lines and generates system call stubs. // Note that sometimes we use a lowercase //sys name and wrap // it in our own nicer implementation, either here or in // syscall_solaris.go or syscall_unix.go. package unix import ( "sync/atomic" "syscall" "unsafe" ) // Implemented in runtime/syscall_solaris.go. type syscallFunc uintptr func rawSysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) func sysvicall6(trap, nargs, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) type SockaddrDatalink struct { Family uint16 Index uint16 Type uint8 Nlen uint8 Alen uint8 Slen uint8 Data [244]int8 raw RawSockaddrDatalink } func clen(n []byte) int { for i := 0; i < len(n); i++ { if n[i] == 0 { return i } } return len(n) } func direntIno(buf []byte) (uint64, bool) { return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino)) } func direntReclen(buf []byte) (uint64, bool) { return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen)) } func direntNamlen(buf []byte) (uint64, bool) { reclen, ok := direntReclen(buf) if !ok { return 0, false } return reclen - uint64(unsafe.Offsetof(Dirent{}.Name)), true } //sysnb pipe(p *[2]_C_int) (n int, err error) func Pipe(p []int) (err error) { if len(p) != 2 { return EINVAL } var pp [2]_C_int n, err := pipe(&pp) if n != 0 { return err } p[0] = int(pp[0]) p[1] = int(pp[1]) return nil } func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Port < 0 || sa.Port > 0xFFFF { return nil, 0, EINVAL } sa.raw.Family = AF_INET p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) for i := 0; i < len(sa.Addr); i++ { sa.raw.Addr[i] = sa.Addr[i] } return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil } func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { if sa.Port < 0 || sa.Port > 0xFFFF { return nil, 0, EINVAL } sa.raw.Family = AF_INET6 p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) p[0] = byte(sa.Port >> 8) p[1] = byte(sa.Port) sa.raw.Scope_id = sa.ZoneId for i := 0; i < len(sa.Addr); i++ { sa.raw.Addr[i] = sa.Addr[i] } return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil } func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { name := sa.Name n := len(name) if n >= len(sa.raw.Path) { return nil, 0, EINVAL } sa.raw.Family = AF_UNIX for i := 0; i < n; i++ { sa.raw.Path[i] = int8(name[i]) } // length is family (uint16), name, NUL. sl := _Socklen(2) if n > 0 { sl += _Socklen(n) + 1 } if sa.raw.Path[0] == '@' { sa.raw.Path[0] = 0 // Don't count trailing NUL for abstract address. sl-- } return unsafe.Pointer(&sa.raw), sl, nil } //sys getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getsockname func Getsockname(fd int) (sa Sockaddr, err error) { var rsa RawSockaddrAny var len _Socklen = SizeofSockaddrAny if err = getsockname(fd, &rsa, &len); err != nil { return } return anyToSockaddr(&rsa) } const ImplementsGetwd = true //sys Getcwd(buf []byte) (n int, err error) func Getwd() (wd string, err error) { var buf [PathMax]byte // Getcwd will return an error if it failed for any reason. _, err = Getcwd(buf[0:]) if err != nil { return "", err } n := clen(buf[:]) if n < 1 { return "", EINVAL } return string(buf[:n]), nil } /* * Wrapped */ //sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error) //sysnb setgroups(ngid int, gid *_Gid_t) (err error) func Getgroups() (gids []int, err error) { n, err := getgroups(0, nil) // Check for error and sanity check group count. Newer versions of // Solaris allow up to 1024 (NGROUPS_MAX). if n < 0 || n > 1024 { if err != nil { return nil, err } return nil, EINVAL } else if n == 0 { return nil, nil } a := make([]_Gid_t, n) n, err = getgroups(n, &a[0]) if n == -1 { return nil, err } gids = make([]int, n) for i, v := range a[0:n] { gids[i] = int(v) } return } func Setgroups(gids []int) (err error) { if len(gids) == 0 { return setgroups(0, nil) } a := make([]_Gid_t, len(gids)) for i, v := range gids { a[i] = _Gid_t(v) } return setgroups(len(a), &a[0]) } func ReadDirent(fd int, buf []byte) (n int, err error) { // Final argument is (basep *uintptr) and the syscall doesn't take nil. // TODO(rsc): Can we use a single global basep for all calls? return Getdents(fd, buf, new(uintptr)) } // Wait status is 7 bits at bottom, either 0 (exited), // 0x7F (stopped), or a signal number that caused an exit. // The 0x80 bit is whether there was a core dump. // An extra number (exit code, signal causing a stop) // is in the high bits. type WaitStatus uint32 const ( mask = 0x7F core = 0x80 shift = 8 exited = 0 stopped = 0x7F ) func (w WaitStatus) Exited() bool { return w&mask == exited } func (w WaitStatus) ExitStatus() int { if w&mask != exited { return -1 } return int(w >> shift) } func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 } func (w WaitStatus) Signal() syscall.Signal { sig := syscall.Signal(w & mask) if sig == stopped || sig == 0 { return -1 } return sig } func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 } func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP } func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP } func (w WaitStatus) StopSignal() syscall.Signal { if !w.Stopped() { return -1 } return syscall.Signal(w>>shift) & 0xFF } func (w WaitStatus) TrapCause() int { return -1 } //sys wait4(pid int32, statusp *_C_int, options int, rusage *Rusage) (wpid int32, err error) func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (int, error) { var status _C_int rpid, err := wait4(int32(pid), &status, options, rusage) wpid := int(rpid) if wpid == -1 { return wpid, err } if wstatus != nil { *wstatus = WaitStatus(status) } return wpid, nil } //sys gethostname(buf []byte) (n int, err error) func Gethostname() (name string, err error) { var buf [MaxHostNameLen]byte n, err := gethostname(buf[:]) if n != 0 { return "", err } n = clen(buf[:]) if n < 1 { return "", EFAULT } return string(buf[:n]), nil } //sys utimes(path string, times *[2]Timeval) (err error) func Utimes(path string, tv []Timeval) (err error) { if tv == nil { return utimes(path, nil) } if len(tv) != 2 { return EINVAL } return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } //sys utimensat(fd int, path string, times *[2]Timespec, flag int) (err error) func UtimesNano(path string, ts []Timespec) error { if ts == nil { return utimensat(AT_FDCWD, path, nil, 0) } if len(ts) != 2 { return EINVAL } return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) } func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { if ts == nil { return utimensat(dirfd, path, nil, flags) } if len(ts) != 2 { return EINVAL } return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) } //sys fcntl(fd int, cmd int, arg int) (val int, err error) // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { _, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procfcntl)), 3, uintptr(fd), uintptr(cmd), uintptr(unsafe.Pointer(lk)), 0, 0, 0) if e1 != 0 { return e1 } return nil } //sys futimesat(fildes int, path *byte, times *[2]Timeval) (err error) func Futimesat(dirfd int, path string, tv []Timeval) error { pathp, err := BytePtrFromString(path) if err != nil { return err } if tv == nil { return futimesat(dirfd, pathp, nil) } if len(tv) != 2 { return EINVAL } return futimesat(dirfd, pathp, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } // Solaris doesn't have an futimes function because it allows NULL to be // specified as the path for futimesat. However, Go doesn't like // NULL-style string interfaces, so this simple wrapper is provided. func Futimes(fd int, tv []Timeval) error { if tv == nil { return futimesat(fd, nil, nil) } if len(tv) != 2 { return EINVAL } return futimesat(fd, nil, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) } func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) { switch rsa.Addr.Family { case AF_UNIX: pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) sa := new(SockaddrUnix) // Assume path ends at NUL. // This is not technically the Solaris semantics for // abstract Unix domain sockets -- they are supposed // to be uninterpreted fixed-size binary blobs -- but // everyone uses this convention. n := 0 for n < len(pp.Path) && pp.Path[n] != 0 { n++ } bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] sa.Name = string(bytes) return sa, nil case AF_INET: pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) sa := new(SockaddrInet4) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) for i := 0; i < len(sa.Addr); i++ { sa.Addr[i] = pp.Addr[i] } return sa, nil case AF_INET6: pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) sa := new(SockaddrInet6) p := (*[2]byte)(unsafe.Pointer(&pp.Port)) sa.Port = int(p[0])<<8 + int(p[1]) sa.ZoneId = pp.Scope_id for i := 0; i < len(sa.Addr); i++ { sa.Addr[i] = pp.Addr[i] } return sa, nil } return nil, EAFNOSUPPORT } //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) = libsocket.accept func Accept(fd int) (nfd int, sa Sockaddr, err error) { var rsa RawSockaddrAny var len _Socklen = SizeofSockaddrAny nfd, err = accept(fd, &rsa, &len) if nfd == -1 { return } sa, err = anyToSockaddr(&rsa) if err != nil { Close(nfd) nfd = 0 } return } //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.__xnet_recvmsg func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { var msg Msghdr var rsa RawSockaddrAny msg.Name = (*byte)(unsafe.Pointer(&rsa)) msg.Namelen = uint32(SizeofSockaddrAny) var iov Iovec if len(p) > 0 { iov.Base = (*int8)(unsafe.Pointer(&p[0])) iov.SetLen(len(p)) } var dummy int8 if len(oob) > 0 { // receive at least one normal byte if len(p) == 0 { iov.Base = &dummy iov.SetLen(1) } msg.Accrightslen = int32(len(oob)) } msg.Iov = &iov msg.Iovlen = 1 if n, err = recvmsg(fd, &msg, flags); n == -1 { return } oobn = int(msg.Accrightslen) // source address is only specified if the socket is unconnected if rsa.Addr.Family != AF_UNSPEC { from, err = anyToSockaddr(&rsa) } return } func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { _, err = SendmsgN(fd, p, oob, to, flags) return } //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = libsocket.__xnet_sendmsg func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { var ptr unsafe.Pointer var salen _Socklen if to != nil { ptr, salen, err = to.sockaddr() if err != nil { return 0, err } } var msg Msghdr msg.Name = (*byte)(unsafe.Pointer(ptr)) msg.Namelen = uint32(salen) var iov Iovec if len(p) > 0 { iov.Base = (*int8)(unsafe.Pointer(&p[0])) iov.SetLen(len(p)) } var dummy int8 if len(oob) > 0 { // send at least one normal byte if len(p) == 0 { iov.Base = &dummy iov.SetLen(1) } msg.Accrightslen = int32(len(oob)) } msg.Iov = &iov msg.Iovlen = 1 if n, err = sendmsg(fd, &msg, flags); err != nil { return 0, err } if len(oob) > 0 && len(p) == 0 { n = 0 } return n, nil } //sys acct(path *byte) (err error) func Acct(path string) (err error) { if len(path) == 0 { // Assume caller wants to disable accounting. return acct(nil) } pathp, err := BytePtrFromString(path) if err != nil { return err } return acct(pathp) } /* * Expose the ioctl function */ //sys ioctl(fd int, req uint, arg uintptr) (err error) func IoctlSetInt(fd int, req uint, value int) (err error) { return ioctl(fd, req, uintptr(value)) } func IoctlSetWinsize(fd int, req uint, value *Winsize) (err error) { return ioctl(fd, req, uintptr(unsafe.Pointer(value))) } func IoctlSetTermios(fd int, req uint, value *Termios) (err error) { return ioctl(fd, req, uintptr(unsafe.Pointer(value))) } func IoctlSetTermio(fd int, req uint, value *Termio) (err error) { return ioctl(fd, req, uintptr(unsafe.Pointer(value))) } func IoctlGetInt(fd int, req uint) (int, error) { var value int err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return value, err } func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { var value Winsize err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return &value, err } func IoctlGetTermios(fd int, req uint) (*Termios, error) { var value Termios err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return &value, err } func IoctlGetTermio(fd int, req uint) (*Termio, error) { var value Termio err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) return &value, err } /* * Exposed directly */ //sys Access(path string, mode uint32) (err error) //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) //sys Chdir(path string) (err error) //sys Chmod(path string, mode uint32) (err error) //sys Chown(path string, uid int, gid int) (err error) //sys Chroot(path string) (err error) //sys Close(fd int) (err error) //sys Creat(path string, mode uint32) (fd int, err error) //sys Dup(fd int) (nfd int, err error) //sys Dup2(oldfd int, newfd int) (err error) //sys Exit(code int) //sys Fchdir(fd int) (err error) //sys Fchmod(fd int, mode uint32) (err error) //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) //sys Fchown(fd int, uid int, gid int) (err error) //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) //sys Fdatasync(fd int) (err error) //sys Flock(fd int, how int) (err error) //sys Fpathconf(fd int, name int) (val int, err error) //sys Fstat(fd int, stat *Stat_t) (err error) //sys Fstatvfs(fd int, vfsstat *Statvfs_t) (err error) //sys Getdents(fd int, buf []byte, basep *uintptr) (n int, err error) //sysnb Getgid() (gid int) //sysnb Getpid() (pid int) //sysnb Getpgid(pid int) (pgid int, err error) //sysnb Getpgrp() (pgid int, err error) //sys Geteuid() (euid int) //sys Getegid() (egid int) //sys Getppid() (ppid int) //sys Getpriority(which int, who int) (n int, err error) //sysnb Getrlimit(which int, lim *Rlimit) (err error) //sysnb Getrusage(who int, rusage *Rusage) (err error) //sysnb Gettimeofday(tv *Timeval) (err error) //sysnb Getuid() (uid int) //sys Kill(pid int, signum syscall.Signal) (err error) //sys Lchown(path string, uid int, gid int) (err error) //sys Link(path string, link string) (err error) //sys Listen(s int, backlog int) (err error) = libsocket.__xnet_llisten //sys Lstat(path string, stat *Stat_t) (err error) //sys Madvise(b []byte, advice int) (err error) //sys Mkdir(path string, mode uint32) (err error) //sys Mkdirat(dirfd int, path string, mode uint32) (err error) //sys Mkfifo(path string, mode uint32) (err error) //sys Mkfifoat(dirfd int, path string, mode uint32) (err error) //sys Mknod(path string, mode uint32, dev int) (err error) //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) //sys Mlock(b []byte) (err error) //sys Mlockall(flags int) (err error) //sys Mprotect(b []byte, prot int) (err error) //sys Munlock(b []byte) (err error) //sys Munlockall() (err error) //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) //sys Open(path string, mode int, perm uint32) (fd int, err error) //sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) //sys Pathconf(path string, name int) (val int, err error) //sys Pause() (err error) //sys Pread(fd int, p []byte, offset int64) (n int, err error) //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) //sys read(fd int, p []byte) (n int, err error) //sys Readlink(path string, buf []byte) (n int, err error) //sys Rename(from string, to string) (err error) //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) //sys Rmdir(path string) (err error) //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = lseek //sysnb Setegid(egid int) (err error) //sysnb Seteuid(euid int) (err error) //sysnb Setgid(gid int) (err error) //sys Sethostname(p []byte) (err error) //sysnb Setpgid(pid int, pgid int) (err error) //sys Setpriority(which int, who int, prio int) (err error) //sysnb Setregid(rgid int, egid int) (err error) //sysnb Setreuid(ruid int, euid int) (err error) //sysnb Setrlimit(which int, lim *Rlimit) (err error) //sysnb Setsid() (pid int, err error) //sysnb Setuid(uid int) (err error) //sys Shutdown(s int, how int) (err error) = libsocket.shutdown //sys Stat(path string, stat *Stat_t) (err error) //sys Statvfs(path string, vfsstat *Statvfs_t) (err error) //sys Symlink(path string, link string) (err error) //sys Sync() (err error) //sysnb Times(tms *Tms) (ticks uintptr, err error) //sys Truncate(path string, length int64) (err error) //sys Fsync(fd int) (err error) //sys Ftruncate(fd int, length int64) (err error) //sys Umask(mask int) (oldmask int) //sysnb Uname(buf *Utsname) (err error) //sys Unmount(target string, flags int) (err error) = libc.umount //sys Unlink(path string) (err error) //sys Unlinkat(dirfd int, path string, flags int) (err error) //sys Ustat(dev int, ubuf *Ustat_t) (err error) //sys Utime(path string, buf *Utimbuf) (err error) //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_bind //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_connect //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) //sys munmap(addr uintptr, length uintptr) (err error) //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) = libsocket.__xnet_sendto //sys socket(domain int, typ int, proto int) (fd int, err error) = libsocket.__xnet_socket //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) = libsocket.__xnet_socketpair //sys write(fd int, p []byte) (n int, err error) //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) = libsocket.__xnet_getsockopt //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) = libsocket.getpeername //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) = libsocket.setsockopt //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) = libsocket.recvfrom func readlen(fd int, buf *byte, nbuf int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procread)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 } return } func writelen(fd int, buf *byte, nbuf int) (n int, err error) { r0, _, e1 := sysvicall6(uintptr(unsafe.Pointer(&procwrite)), 3, uintptr(fd), uintptr(unsafe.Pointer(buf)), uintptr(nbuf), 0, 0, 0) n = int(r0) if e1 != 0 { err = e1 } return } var mapper = &mmapper{ active: make(map[*byte][]byte), mmap: mmap, munmap: munmap, } func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { return mapper.Mmap(fd, offset, length, prot, flags) } func Munmap(b []byte) (err error) { return mapper.Munmap(b) } //sys sysconf(name int) (n int64, err error) // pageSize caches the value of Getpagesize, since it can't change // once the system is booted. var pageSize int64 // accessed atomically func Getpagesize() int { n := atomic.LoadInt64(&pageSize) if n == 0 { n, _ = sysconf(_SC_PAGESIZE) atomic.StoreInt64(&pageSize, n) } return int(n) }
dep/vendor/golang.org/x/sys/unix/syscall_solaris.go/0
{ "file_path": "dep/vendor/golang.org/x/sys/unix/syscall_solaris.go", "repo_id": "dep", "token_count": 8464 }
48
package yaml import ( "bytes" "fmt" ) // Introduction // ************ // // The following notes assume that you are familiar with the YAML specification // (http://yaml.org/spec/1.2/spec.html). We mostly follow it, although in // some cases we are less restrictive that it requires. // // The process of transforming a YAML stream into a sequence of events is // divided on two steps: Scanning and Parsing. // // The Scanner transforms the input stream into a sequence of tokens, while the // parser transform the sequence of tokens produced by the Scanner into a // sequence of parsing events. // // The Scanner is rather clever and complicated. The Parser, on the contrary, // is a straightforward implementation of a recursive-descendant parser (or, // LL(1) parser, as it is usually called). // // Actually there are two issues of Scanning that might be called "clever", the // rest is quite straightforward. The issues are "block collection start" and // "simple keys". Both issues are explained below in details. // // Here the Scanning step is explained and implemented. We start with the list // of all the tokens produced by the Scanner together with short descriptions. // // Now, tokens: // // STREAM-START(encoding) # The stream start. // STREAM-END # The stream end. // VERSION-DIRECTIVE(major,minor) # The '%YAML' directive. // TAG-DIRECTIVE(handle,prefix) # The '%TAG' directive. // DOCUMENT-START # '---' // DOCUMENT-END # '...' // BLOCK-SEQUENCE-START # Indentation increase denoting a block // BLOCK-MAPPING-START # sequence or a block mapping. // BLOCK-END # Indentation decrease. // FLOW-SEQUENCE-START # '[' // FLOW-SEQUENCE-END # ']' // BLOCK-SEQUENCE-START # '{' // BLOCK-SEQUENCE-END # '}' // BLOCK-ENTRY # '-' // FLOW-ENTRY # ',' // KEY # '?' or nothing (simple keys). // VALUE # ':' // ALIAS(anchor) # '*anchor' // ANCHOR(anchor) # '&anchor' // TAG(handle,suffix) # '!handle!suffix' // SCALAR(value,style) # A scalar. // // The following two tokens are "virtual" tokens denoting the beginning and the // end of the stream: // // STREAM-START(encoding) // STREAM-END // // We pass the information about the input stream encoding with the // STREAM-START token. // // The next two tokens are responsible for tags: // // VERSION-DIRECTIVE(major,minor) // TAG-DIRECTIVE(handle,prefix) // // Example: // // %YAML 1.1 // %TAG ! !foo // %TAG !yaml! tag:yaml.org,2002: // --- // // The correspoding sequence of tokens: // // STREAM-START(utf-8) // VERSION-DIRECTIVE(1,1) // TAG-DIRECTIVE("!","!foo") // TAG-DIRECTIVE("!yaml","tag:yaml.org,2002:") // DOCUMENT-START // STREAM-END // // Note that the VERSION-DIRECTIVE and TAG-DIRECTIVE tokens occupy a whole // line. // // The document start and end indicators are represented by: // // DOCUMENT-START // DOCUMENT-END // // Note that if a YAML stream contains an implicit document (without '---' // and '...' indicators), no DOCUMENT-START and DOCUMENT-END tokens will be // produced. // // In the following examples, we present whole documents together with the // produced tokens. // // 1. An implicit document: // // 'a scalar' // // Tokens: // // STREAM-START(utf-8) // SCALAR("a scalar",single-quoted) // STREAM-END // // 2. An explicit document: // // --- // 'a scalar' // ... // // Tokens: // // STREAM-START(utf-8) // DOCUMENT-START // SCALAR("a scalar",single-quoted) // DOCUMENT-END // STREAM-END // // 3. Several documents in a stream: // // 'a scalar' // --- // 'another scalar' // --- // 'yet another scalar' // // Tokens: // // STREAM-START(utf-8) // SCALAR("a scalar",single-quoted) // DOCUMENT-START // SCALAR("another scalar",single-quoted) // DOCUMENT-START // SCALAR("yet another scalar",single-quoted) // STREAM-END // // We have already introduced the SCALAR token above. The following tokens are // used to describe aliases, anchors, tag, and scalars: // // ALIAS(anchor) // ANCHOR(anchor) // TAG(handle,suffix) // SCALAR(value,style) // // The following series of examples illustrate the usage of these tokens: // // 1. A recursive sequence: // // &A [ *A ] // // Tokens: // // STREAM-START(utf-8) // ANCHOR("A") // FLOW-SEQUENCE-START // ALIAS("A") // FLOW-SEQUENCE-END // STREAM-END // // 2. A tagged scalar: // // !!float "3.14" # A good approximation. // // Tokens: // // STREAM-START(utf-8) // TAG("!!","float") // SCALAR("3.14",double-quoted) // STREAM-END // // 3. Various scalar styles: // // --- # Implicit empty plain scalars do not produce tokens. // --- a plain scalar // --- 'a single-quoted scalar' // --- "a double-quoted scalar" // --- |- // a literal scalar // --- >- // a folded // scalar // // Tokens: // // STREAM-START(utf-8) // DOCUMENT-START // DOCUMENT-START // SCALAR("a plain scalar",plain) // DOCUMENT-START // SCALAR("a single-quoted scalar",single-quoted) // DOCUMENT-START // SCALAR("a double-quoted scalar",double-quoted) // DOCUMENT-START // SCALAR("a literal scalar",literal) // DOCUMENT-START // SCALAR("a folded scalar",folded) // STREAM-END // // Now it's time to review collection-related tokens. We will start with // flow collections: // // FLOW-SEQUENCE-START // FLOW-SEQUENCE-END // FLOW-MAPPING-START // FLOW-MAPPING-END // FLOW-ENTRY // KEY // VALUE // // The tokens FLOW-SEQUENCE-START, FLOW-SEQUENCE-END, FLOW-MAPPING-START, and // FLOW-MAPPING-END represent the indicators '[', ']', '{', and '}' // correspondingly. FLOW-ENTRY represent the ',' indicator. Finally the // indicators '?' and ':', which are used for denoting mapping keys and values, // are represented by the KEY and VALUE tokens. // // The following examples show flow collections: // // 1. A flow sequence: // // [item 1, item 2, item 3] // // Tokens: // // STREAM-START(utf-8) // FLOW-SEQUENCE-START // SCALAR("item 1",plain) // FLOW-ENTRY // SCALAR("item 2",plain) // FLOW-ENTRY // SCALAR("item 3",plain) // FLOW-SEQUENCE-END // STREAM-END // // 2. A flow mapping: // // { // a simple key: a value, # Note that the KEY token is produced. // ? a complex key: another value, // } // // Tokens: // // STREAM-START(utf-8) // FLOW-MAPPING-START // KEY // SCALAR("a simple key",plain) // VALUE // SCALAR("a value",plain) // FLOW-ENTRY // KEY // SCALAR("a complex key",plain) // VALUE // SCALAR("another value",plain) // FLOW-ENTRY // FLOW-MAPPING-END // STREAM-END // // A simple key is a key which is not denoted by the '?' indicator. Note that // the Scanner still produce the KEY token whenever it encounters a simple key. // // For scanning block collections, the following tokens are used (note that we // repeat KEY and VALUE here): // // BLOCK-SEQUENCE-START // BLOCK-MAPPING-START // BLOCK-END // BLOCK-ENTRY // KEY // VALUE // // The tokens BLOCK-SEQUENCE-START and BLOCK-MAPPING-START denote indentation // increase that precedes a block collection (cf. the INDENT token in Python). // The token BLOCK-END denote indentation decrease that ends a block collection // (cf. the DEDENT token in Python). However YAML has some syntax pecularities // that makes detections of these tokens more complex. // // The tokens BLOCK-ENTRY, KEY, and VALUE are used to represent the indicators // '-', '?', and ':' correspondingly. // // The following examples show how the tokens BLOCK-SEQUENCE-START, // BLOCK-MAPPING-START, and BLOCK-END are emitted by the Scanner: // // 1. Block sequences: // // - item 1 // - item 2 // - // - item 3.1 // - item 3.2 // - // key 1: value 1 // key 2: value 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-ENTRY // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 3.1",plain) // BLOCK-ENTRY // SCALAR("item 3.2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // 2. Block mappings: // // a simple key: a value # The KEY token is produced here. // ? a complex key // : another value // a mapping: // key 1: value 1 // key 2: value 2 // a sequence: // - item 1 // - item 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("a simple key",plain) // VALUE // SCALAR("a value",plain) // KEY // SCALAR("a complex key",plain) // VALUE // SCALAR("another value",plain) // KEY // SCALAR("a mapping",plain) // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // KEY // SCALAR("a sequence",plain) // VALUE // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // YAML does not always require to start a new block collection from a new // line. If the current line contains only '-', '?', and ':' indicators, a new // block collection may start at the current line. The following examples // illustrate this case: // // 1. Collections in a sequence: // // - - item 1 // - item 2 // - key 1: value 1 // key 2: value 2 // - ? complex key // : complex value // // Tokens: // // STREAM-START(utf-8) // BLOCK-SEQUENCE-START // BLOCK-ENTRY // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-ENTRY // BLOCK-MAPPING-START // KEY // SCALAR("complex key") // VALUE // SCALAR("complex value") // BLOCK-END // BLOCK-END // STREAM-END // // 2. Collections in a mapping: // // ? a sequence // : - item 1 // - item 2 // ? a mapping // : key 1: value 1 // key 2: value 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("a sequence",plain) // VALUE // BLOCK-SEQUENCE-START // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // KEY // SCALAR("a mapping",plain) // VALUE // BLOCK-MAPPING-START // KEY // SCALAR("key 1",plain) // VALUE // SCALAR("value 1",plain) // KEY // SCALAR("key 2",plain) // VALUE // SCALAR("value 2",plain) // BLOCK-END // BLOCK-END // STREAM-END // // YAML also permits non-indented sequences if they are included into a block // mapping. In this case, the token BLOCK-SEQUENCE-START is not produced: // // key: // - item 1 # BLOCK-SEQUENCE-START is NOT produced here. // - item 2 // // Tokens: // // STREAM-START(utf-8) // BLOCK-MAPPING-START // KEY // SCALAR("key",plain) // VALUE // BLOCK-ENTRY // SCALAR("item 1",plain) // BLOCK-ENTRY // SCALAR("item 2",plain) // BLOCK-END // // Ensure that the buffer contains the required number of characters. // Return true on success, false on failure (reader error or memory error). func cache(parser *yaml_parser_t, length int) bool { // [Go] This was inlined: !cache(A, B) -> unread < B && !update(A, B) return parser.unread >= length || yaml_parser_update_buffer(parser, length) } // Advance the buffer pointer. func skip(parser *yaml_parser_t) { parser.mark.index++ parser.mark.column++ parser.unread-- parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) } func skip_line(parser *yaml_parser_t) { if is_crlf(parser.buffer, parser.buffer_pos) { parser.mark.index += 2 parser.mark.column = 0 parser.mark.line++ parser.unread -= 2 parser.buffer_pos += 2 } else if is_break(parser.buffer, parser.buffer_pos) { parser.mark.index++ parser.mark.column = 0 parser.mark.line++ parser.unread-- parser.buffer_pos += width(parser.buffer[parser.buffer_pos]) } } // Copy a character to a string buffer and advance pointers. func read(parser *yaml_parser_t, s []byte) []byte { w := width(parser.buffer[parser.buffer_pos]) if w == 0 { panic("invalid character sequence") } if len(s) == 0 { s = make([]byte, 0, 32) } if w == 1 && len(s)+w <= cap(s) { s = s[:len(s)+1] s[len(s)-1] = parser.buffer[parser.buffer_pos] parser.buffer_pos++ } else { s = append(s, parser.buffer[parser.buffer_pos:parser.buffer_pos+w]...) parser.buffer_pos += w } parser.mark.index++ parser.mark.column++ parser.unread-- return s } // Copy a line break character to a string buffer and advance pointers. func read_line(parser *yaml_parser_t, s []byte) []byte { buf := parser.buffer pos := parser.buffer_pos switch { case buf[pos] == '\r' && buf[pos+1] == '\n': // CR LF . LF s = append(s, '\n') parser.buffer_pos += 2 parser.mark.index++ parser.unread-- case buf[pos] == '\r' || buf[pos] == '\n': // CR|LF . LF s = append(s, '\n') parser.buffer_pos += 1 case buf[pos] == '\xC2' && buf[pos+1] == '\x85': // NEL . LF s = append(s, '\n') parser.buffer_pos += 2 case buf[pos] == '\xE2' && buf[pos+1] == '\x80' && (buf[pos+2] == '\xA8' || buf[pos+2] == '\xA9'): // LS|PS . LS|PS s = append(s, buf[parser.buffer_pos:pos+3]...) parser.buffer_pos += 3 default: return s } parser.mark.index++ parser.mark.column = 0 parser.mark.line++ parser.unread-- return s } // Get the next token. func yaml_parser_scan(parser *yaml_parser_t, token *yaml_token_t) bool { // Erase the token object. *token = yaml_token_t{} // [Go] Is this necessary? // No tokens after STREAM-END or error. if parser.stream_end_produced || parser.error != yaml_NO_ERROR { return true } // Ensure that the tokens queue contains enough tokens. if !parser.token_available { if !yaml_parser_fetch_more_tokens(parser) { return false } } // Fetch the next token from the queue. *token = parser.tokens[parser.tokens_head] parser.tokens_head++ parser.tokens_parsed++ parser.token_available = false if token.typ == yaml_STREAM_END_TOKEN { parser.stream_end_produced = true } return true } // Set the scanner error and return false. func yaml_parser_set_scanner_error(parser *yaml_parser_t, context string, context_mark yaml_mark_t, problem string) bool { parser.error = yaml_SCANNER_ERROR parser.context = context parser.context_mark = context_mark parser.problem = problem parser.problem_mark = parser.mark return false } func yaml_parser_set_scanner_tag_error(parser *yaml_parser_t, directive bool, context_mark yaml_mark_t, problem string) bool { context := "while parsing a tag" if directive { context = "while parsing a %TAG directive" } return yaml_parser_set_scanner_error(parser, context, context_mark, problem) } func trace(args ...interface{}) func() { pargs := append([]interface{}{"+++"}, args...) fmt.Println(pargs...) pargs = append([]interface{}{"---"}, args...) return func() { fmt.Println(pargs...) } } // Ensure that the tokens queue contains at least one token which can be // returned to the Parser. func yaml_parser_fetch_more_tokens(parser *yaml_parser_t) bool { // While we need more tokens to fetch, do it. for { // Check if we really need to fetch more tokens. need_more_tokens := false if parser.tokens_head == len(parser.tokens) { // Queue is empty. need_more_tokens = true } else { // Check if any potential simple key may occupy the head position. if !yaml_parser_stale_simple_keys(parser) { return false } for i := range parser.simple_keys { simple_key := &parser.simple_keys[i] if simple_key.possible && simple_key.token_number == parser.tokens_parsed { need_more_tokens = true break } } } // We are finished. if !need_more_tokens { break } // Fetch the next token. if !yaml_parser_fetch_next_token(parser) { return false } } parser.token_available = true return true } // The dispatcher for token fetchers. func yaml_parser_fetch_next_token(parser *yaml_parser_t) bool { // Ensure that the buffer is initialized. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } // Check if we just started scanning. Fetch STREAM-START then. if !parser.stream_start_produced { return yaml_parser_fetch_stream_start(parser) } // Eat whitespaces and comments until we reach the next token. if !yaml_parser_scan_to_next_token(parser) { return false } // Remove obsolete potential simple keys. if !yaml_parser_stale_simple_keys(parser) { return false } // Check the indentation level against the current column. if !yaml_parser_unroll_indent(parser, parser.mark.column) { return false } // Ensure that the buffer contains at least 4 characters. 4 is the length // of the longest indicators ('--- ' and '... '). if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { return false } // Is it the end of the stream? if is_z(parser.buffer, parser.buffer_pos) { return yaml_parser_fetch_stream_end(parser) } // Is it a directive? if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' { return yaml_parser_fetch_directive(parser) } buf := parser.buffer pos := parser.buffer_pos // Is it the document start indicator? if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) { return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN) } // Is it the document end indicator? if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) { return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN) } // Is it the flow sequence start indicator? if buf[pos] == '[' { return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_SEQUENCE_START_TOKEN) } // Is it the flow mapping start indicator? if parser.buffer[parser.buffer_pos] == '{' { return yaml_parser_fetch_flow_collection_start(parser, yaml_FLOW_MAPPING_START_TOKEN) } // Is it the flow sequence end indicator? if parser.buffer[parser.buffer_pos] == ']' { return yaml_parser_fetch_flow_collection_end(parser, yaml_FLOW_SEQUENCE_END_TOKEN) } // Is it the flow mapping end indicator? if parser.buffer[parser.buffer_pos] == '}' { return yaml_parser_fetch_flow_collection_end(parser, yaml_FLOW_MAPPING_END_TOKEN) } // Is it the flow entry indicator? if parser.buffer[parser.buffer_pos] == ',' { return yaml_parser_fetch_flow_entry(parser) } // Is it the block entry indicator? if parser.buffer[parser.buffer_pos] == '-' && is_blankz(parser.buffer, parser.buffer_pos+1) { return yaml_parser_fetch_block_entry(parser) } // Is it the key indicator? if parser.buffer[parser.buffer_pos] == '?' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_key(parser) } // Is it the value indicator? if parser.buffer[parser.buffer_pos] == ':' && (parser.flow_level > 0 || is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_value(parser) } // Is it an alias? if parser.buffer[parser.buffer_pos] == '*' { return yaml_parser_fetch_anchor(parser, yaml_ALIAS_TOKEN) } // Is it an anchor? if parser.buffer[parser.buffer_pos] == '&' { return yaml_parser_fetch_anchor(parser, yaml_ANCHOR_TOKEN) } // Is it a tag? if parser.buffer[parser.buffer_pos] == '!' { return yaml_parser_fetch_tag(parser) } // Is it a literal scalar? if parser.buffer[parser.buffer_pos] == '|' && parser.flow_level == 0 { return yaml_parser_fetch_block_scalar(parser, true) } // Is it a folded scalar? if parser.buffer[parser.buffer_pos] == '>' && parser.flow_level == 0 { return yaml_parser_fetch_block_scalar(parser, false) } // Is it a single-quoted scalar? if parser.buffer[parser.buffer_pos] == '\'' { return yaml_parser_fetch_flow_scalar(parser, true) } // Is it a double-quoted scalar? if parser.buffer[parser.buffer_pos] == '"' { return yaml_parser_fetch_flow_scalar(parser, false) } // Is it a plain scalar? // // A plain scalar may start with any non-blank characters except // // '-', '?', ':', ',', '[', ']', '{', '}', // '#', '&', '*', '!', '|', '>', '\'', '\"', // '%', '@', '`'. // // In the block context (and, for the '-' indicator, in the flow context // too), it may also start with the characters // // '-', '?', ':' // // if it is followed by a non-space character. // // The last rule is more restrictive than the specification requires. // [Go] Make this logic more reasonable. //switch parser.buffer[parser.buffer_pos] { //case '-', '?', ':', ',', '?', '-', ',', ':', ']', '[', '}', '{', '&', '#', '!', '*', '>', '|', '"', '\'', '@', '%', '-', '`': //} if !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '-' || parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '#' || parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '|' || parser.buffer[parser.buffer_pos] == '>' || parser.buffer[parser.buffer_pos] == '\'' || parser.buffer[parser.buffer_pos] == '"' || parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') || (parser.buffer[parser.buffer_pos] == '-' && !is_blank(parser.buffer, parser.buffer_pos+1)) || (parser.flow_level == 0 && (parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':') && !is_blankz(parser.buffer, parser.buffer_pos+1)) { return yaml_parser_fetch_plain_scalar(parser) } // If we don't determine the token type so far, it is an error. return yaml_parser_set_scanner_error(parser, "while scanning for the next token", parser.mark, "found character that cannot start any token") } // Check the list of potential simple keys and remove the positions that // cannot contain simple keys anymore. func yaml_parser_stale_simple_keys(parser *yaml_parser_t) bool { // Check for a potential simple key for each flow level. for i := range parser.simple_keys { simple_key := &parser.simple_keys[i] // The specification requires that a simple key // // - is limited to a single line, // - is shorter than 1024 characters. if simple_key.possible && (simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index) { // Check if the potential simple key to be removed is required. if simple_key.required { return yaml_parser_set_scanner_error(parser, "while scanning a simple key", simple_key.mark, "could not find expected ':'") } simple_key.possible = false } } return true } // Check if a simple key may start at the current position and add it if // needed. func yaml_parser_save_simple_key(parser *yaml_parser_t) bool { // A simple key is required at the current position if the scanner is in // the block context and the current column coincides with the indentation // level. required := parser.flow_level == 0 && parser.indent == parser.mark.column // A simple key is required only when it is the first token in the current // line. Therefore it is always allowed. But we add a check anyway. if required && !parser.simple_key_allowed { panic("should not happen") } // // If the current position may start a simple key, save it. // if parser.simple_key_allowed { simple_key := yaml_simple_key_t{ possible: true, required: required, token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head), } simple_key.mark = parser.mark if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_keys[len(parser.simple_keys)-1] = simple_key } return true } // Remove a potential simple key at the current flow level. func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool { i := len(parser.simple_keys) - 1 if parser.simple_keys[i].possible { // If the key is required, it is an error. if parser.simple_keys[i].required { return yaml_parser_set_scanner_error(parser, "while scanning a simple key", parser.simple_keys[i].mark, "could not find expected ':'") } } // Remove the key from the stack. parser.simple_keys[i].possible = false return true } // Increase the flow level and resize the simple key list if needed. func yaml_parser_increase_flow_level(parser *yaml_parser_t) bool { // Reset the simple key on the next level. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) // Increase the flow level. parser.flow_level++ return true } // Decrease the flow level. func yaml_parser_decrease_flow_level(parser *yaml_parser_t) bool { if parser.flow_level > 0 { parser.flow_level-- parser.simple_keys = parser.simple_keys[:len(parser.simple_keys)-1] } return true } // Push the current indentation level to the stack and set the new level // the current column is greater than the indentation level. In this case, // append or insert the specified token into the token queue. func yaml_parser_roll_indent(parser *yaml_parser_t, column, number int, typ yaml_token_type_t, mark yaml_mark_t) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } if parser.indent < column { // Push the current indentation level to the stack and set the new // indentation level. parser.indents = append(parser.indents, parser.indent) parser.indent = column // Create a token and insert it into the queue. token := yaml_token_t{ typ: typ, start_mark: mark, end_mark: mark, } if number > -1 { number -= parser.tokens_parsed } yaml_insert_token(parser, number, &token) } return true } // Pop indentation levels from the indents stack until the current level // becomes less or equal to the column. For each indentation level, append // the BLOCK-END token. func yaml_parser_unroll_indent(parser *yaml_parser_t, column int) bool { // In the flow context, do nothing. if parser.flow_level > 0 { return true } // Loop through the indentation levels in the stack. for parser.indent > column { // Create a token and append it to the queue. token := yaml_token_t{ typ: yaml_BLOCK_END_TOKEN, start_mark: parser.mark, end_mark: parser.mark, } yaml_insert_token(parser, -1, &token) // Pop the indentation level. parser.indent = parser.indents[len(parser.indents)-1] parser.indents = parser.indents[:len(parser.indents)-1] } return true } // Initialize the scanner and produce the STREAM-START token. func yaml_parser_fetch_stream_start(parser *yaml_parser_t) bool { // Set the initial indentation. parser.indent = -1 // Initialize the simple key stack. parser.simple_keys = append(parser.simple_keys, yaml_simple_key_t{}) // A simple key is allowed at the beginning of the stream. parser.simple_key_allowed = true // We have started. parser.stream_start_produced = true // Create the STREAM-START token and append it to the queue. token := yaml_token_t{ typ: yaml_STREAM_START_TOKEN, start_mark: parser.mark, end_mark: parser.mark, encoding: parser.encoding, } yaml_insert_token(parser, -1, &token) return true } // Produce the STREAM-END token and shut down the scanner. func yaml_parser_fetch_stream_end(parser *yaml_parser_t) bool { // Force new line. if parser.mark.column != 0 { parser.mark.column = 0 parser.mark.line++ } // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Create the STREAM-END token and append it to the queue. token := yaml_token_t{ typ: yaml_STREAM_END_TOKEN, start_mark: parser.mark, end_mark: parser.mark, } yaml_insert_token(parser, -1, &token) return true } // Produce a VERSION-DIRECTIVE or TAG-DIRECTIVE token. func yaml_parser_fetch_directive(parser *yaml_parser_t) bool { // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Create the YAML-DIRECTIVE or TAG-DIRECTIVE token. token := yaml_token_t{} if !yaml_parser_scan_directive(parser, &token) { return false } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true } // Produce the DOCUMENT-START or DOCUMENT-END token. func yaml_parser_fetch_document_indicator(parser *yaml_parser_t, typ yaml_token_type_t) bool { // Reset the indentation level. if !yaml_parser_unroll_indent(parser, -1) { return false } // Reset simple keys. if !yaml_parser_remove_simple_key(parser) { return false } parser.simple_key_allowed = false // Consume the token. start_mark := parser.mark skip(parser) skip(parser) skip(parser) end_mark := parser.mark // Create the DOCUMENT-START or DOCUMENT-END token. token := yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true } // Produce the FLOW-SEQUENCE-START or FLOW-MAPPING-START token. func yaml_parser_fetch_flow_collection_start(parser *yaml_parser_t, typ yaml_token_type_t) bool { // The indicators '[' and '{' may start a simple key. if !yaml_parser_save_simple_key(parser) { return false } // Increase the flow level. if !yaml_parser_increase_flow_level(parser) { return false } // A simple key may follow the indicators '[' and '{'. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the FLOW-SEQUENCE-START of FLOW-MAPPING-START token. token := yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true } // Produce the FLOW-SEQUENCE-END or FLOW-MAPPING-END token. func yaml_parser_fetch_flow_collection_end(parser *yaml_parser_t, typ yaml_token_type_t) bool { // Reset any potential simple key on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Decrease the flow level. if !yaml_parser_decrease_flow_level(parser) { return false } // No simple keys after the indicators ']' and '}'. parser.simple_key_allowed = false // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the FLOW-SEQUENCE-END of FLOW-MAPPING-END token. token := yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, } // Append the token to the queue. yaml_insert_token(parser, -1, &token) return true } // Produce the FLOW-ENTRY token. func yaml_parser_fetch_flow_entry(parser *yaml_parser_t) bool { // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after ','. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the FLOW-ENTRY token and append it to the queue. token := yaml_token_t{ typ: yaml_FLOW_ENTRY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true } // Produce the BLOCK-ENTRY token. func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool { // Check if the scanner is in the block context. if parser.flow_level == 0 { // Check if we are allowed to start a new entry. if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "block sequence entries are not allowed in this context") } // Add the BLOCK-SEQUENCE-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) { return false } } else { // It is an error for the '-' indicator to occur in the flow context, // but we let the Parser detect and report about it because the Parser // is able to point to the context. } // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after '-'. parser.simple_key_allowed = true // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the BLOCK-ENTRY token and append it to the queue. token := yaml_token_t{ typ: yaml_BLOCK_ENTRY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true } // Produce the KEY token. func yaml_parser_fetch_key(parser *yaml_parser_t) bool { // In the block context, additional checks are required. if parser.flow_level == 0 { // Check if we are allowed to start a new key (not nessesary simple). if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "mapping keys are not allowed in this context") } // Add the BLOCK-MAPPING-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { return false } } // Reset any potential simple keys on the current flow level. if !yaml_parser_remove_simple_key(parser) { return false } // Simple keys are allowed after '?' in the block context. parser.simple_key_allowed = parser.flow_level == 0 // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the KEY token and append it to the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true } // Produce the VALUE token. func yaml_parser_fetch_value(parser *yaml_parser_t) bool { simple_key := &parser.simple_keys[len(parser.simple_keys)-1] // Have we found a simple key? if simple_key.possible { // Create the KEY token and insert it into the queue. token := yaml_token_t{ typ: yaml_KEY_TOKEN, start_mark: simple_key.mark, end_mark: simple_key.mark, } yaml_insert_token(parser, simple_key.token_number-parser.tokens_parsed, &token) // In the block context, we may need to add the BLOCK-MAPPING-START token. if !yaml_parser_roll_indent(parser, simple_key.mark.column, simple_key.token_number, yaml_BLOCK_MAPPING_START_TOKEN, simple_key.mark) { return false } // Remove the simple key. simple_key.possible = false // A simple key cannot follow another simple key. parser.simple_key_allowed = false } else { // The ':' indicator follows a complex key. // In the block context, extra checks are required. if parser.flow_level == 0 { // Check if we are allowed to start a complex value. if !parser.simple_key_allowed { return yaml_parser_set_scanner_error(parser, "", parser.mark, "mapping values are not allowed in this context") } // Add the BLOCK-MAPPING-START token if needed. if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) { return false } } // Simple keys after ':' are allowed in the block context. parser.simple_key_allowed = parser.flow_level == 0 } // Consume the token. start_mark := parser.mark skip(parser) end_mark := parser.mark // Create the VALUE token and append it to the queue. token := yaml_token_t{ typ: yaml_VALUE_TOKEN, start_mark: start_mark, end_mark: end_mark, } yaml_insert_token(parser, -1, &token) return true } // Produce the ALIAS or ANCHOR token. func yaml_parser_fetch_anchor(parser *yaml_parser_t, typ yaml_token_type_t) bool { // An anchor or an alias could be a simple key. if !yaml_parser_save_simple_key(parser) { return false } // A simple key cannot follow an anchor or an alias. parser.simple_key_allowed = false // Create the ALIAS or ANCHOR token and append it to the queue. var token yaml_token_t if !yaml_parser_scan_anchor(parser, &token, typ) { return false } yaml_insert_token(parser, -1, &token) return true } // Produce the TAG token. func yaml_parser_fetch_tag(parser *yaml_parser_t) bool { // A tag could be a simple key. if !yaml_parser_save_simple_key(parser) { return false } // A simple key cannot follow a tag. parser.simple_key_allowed = false // Create the TAG token and append it to the queue. var token yaml_token_t if !yaml_parser_scan_tag(parser, &token) { return false } yaml_insert_token(parser, -1, &token) return true } // Produce the SCALAR(...,literal) or SCALAR(...,folded) tokens. func yaml_parser_fetch_block_scalar(parser *yaml_parser_t, literal bool) bool { // Remove any potential simple keys. if !yaml_parser_remove_simple_key(parser) { return false } // A simple key may follow a block scalar. parser.simple_key_allowed = true // Create the SCALAR token and append it to the queue. var token yaml_token_t if !yaml_parser_scan_block_scalar(parser, &token, literal) { return false } yaml_insert_token(parser, -1, &token) return true } // Produce the SCALAR(...,single-quoted) or SCALAR(...,double-quoted) tokens. func yaml_parser_fetch_flow_scalar(parser *yaml_parser_t, single bool) bool { // A plain scalar could be a simple key. if !yaml_parser_save_simple_key(parser) { return false } // A simple key cannot follow a flow scalar. parser.simple_key_allowed = false // Create the SCALAR token and append it to the queue. var token yaml_token_t if !yaml_parser_scan_flow_scalar(parser, &token, single) { return false } yaml_insert_token(parser, -1, &token) return true } // Produce the SCALAR(...,plain) token. func yaml_parser_fetch_plain_scalar(parser *yaml_parser_t) bool { // A plain scalar could be a simple key. if !yaml_parser_save_simple_key(parser) { return false } // A simple key cannot follow a flow scalar. parser.simple_key_allowed = false // Create the SCALAR token and append it to the queue. var token yaml_token_t if !yaml_parser_scan_plain_scalar(parser, &token) { return false } yaml_insert_token(parser, -1, &token) return true } // Eat whitespaces and comments until the next token is found. func yaml_parser_scan_to_next_token(parser *yaml_parser_t) bool { // Until the next token is not found. for { // Allow the BOM mark to start a line. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } if parser.mark.column == 0 && is_bom(parser.buffer, parser.buffer_pos) { skip(parser) } // Eat whitespaces. // Tabs are allowed: // - in the flow context // - in the block context, but not at the beginning of the line or // after '-', '?', or ':' (complex value). if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for parser.buffer[parser.buffer_pos] == ' ' || ((parser.flow_level > 0 || !parser.simple_key_allowed) && parser.buffer[parser.buffer_pos] == '\t') { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Eat a comment until a line break. if parser.buffer[parser.buffer_pos] == '#' { for !is_breakz(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } } // If it is a line break, eat it. if is_break(parser.buffer, parser.buffer_pos) { if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } skip_line(parser) // In the block context, a new line may start a simple key. if parser.flow_level == 0 { parser.simple_key_allowed = true } } else { break // We have found a token. } } return true } // Scan a YAML-DIRECTIVE or TAG-DIRECTIVE token. // // Scope: // %YAML 1.1 # a comment \n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // %TAG !yaml! tag:yaml.org,2002: \n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool { // Eat '%'. start_mark := parser.mark skip(parser) // Scan the directive name. var name []byte if !yaml_parser_scan_directive_name(parser, start_mark, &name) { return false } // Is it a YAML directive? if bytes.Equal(name, []byte("YAML")) { // Scan the VERSION directive value. var major, minor int8 if !yaml_parser_scan_version_directive_value(parser, start_mark, &major, &minor) { return false } end_mark := parser.mark // Create a VERSION-DIRECTIVE token. *token = yaml_token_t{ typ: yaml_VERSION_DIRECTIVE_TOKEN, start_mark: start_mark, end_mark: end_mark, major: major, minor: minor, } // Is it a TAG directive? } else if bytes.Equal(name, []byte("TAG")) { // Scan the TAG directive value. var handle, prefix []byte if !yaml_parser_scan_tag_directive_value(parser, start_mark, &handle, &prefix) { return false } end_mark := parser.mark // Create a TAG-DIRECTIVE token. *token = yaml_token_t{ typ: yaml_TAG_DIRECTIVE_TOKEN, start_mark: start_mark, end_mark: end_mark, value: handle, prefix: prefix, } // Unknown directive. } else { yaml_parser_set_scanner_error(parser, "while scanning a directive", start_mark, "found unknown directive name") return false } // Eat the rest of the line including any comments. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for is_blank(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } if parser.buffer[parser.buffer_pos] == '#' { for !is_breakz(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } } // Check if we are at the end of the line. if !is_breakz(parser.buffer, parser.buffer_pos) { yaml_parser_set_scanner_error(parser, "while scanning a directive", start_mark, "did not find expected comment or line break") return false } // Eat a line break. if is_break(parser.buffer, parser.buffer_pos) { if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } skip_line(parser) } return true } // Scan the directive name. // // Scope: // %YAML 1.1 # a comment \n // ^^^^ // %TAG !yaml! tag:yaml.org,2002: \n // ^^^ // func yaml_parser_scan_directive_name(parser *yaml_parser_t, start_mark yaml_mark_t, name *[]byte) bool { // Consume the directive name. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } var s []byte for is_alpha(parser.buffer, parser.buffer_pos) { s = read(parser, s) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Check if the name is empty. if len(s) == 0 { yaml_parser_set_scanner_error(parser, "while scanning a directive", start_mark, "could not find expected directive name") return false } // Check for an blank character after the name. if !is_blankz(parser.buffer, parser.buffer_pos) { yaml_parser_set_scanner_error(parser, "while scanning a directive", start_mark, "found unexpected non-alphabetical character") return false } *name = s return true } // Scan the value of VERSION-DIRECTIVE. // // Scope: // %YAML 1.1 # a comment \n // ^^^^^^ func yaml_parser_scan_version_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, major, minor *int8) bool { // Eat whitespaces. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for is_blank(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Consume the major version number. if !yaml_parser_scan_version_directive_number(parser, start_mark, major) { return false } // Eat '.'. if parser.buffer[parser.buffer_pos] != '.' { return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", start_mark, "did not find expected digit or '.' character") } skip(parser) // Consume the minor version number. if !yaml_parser_scan_version_directive_number(parser, start_mark, minor) { return false } return true } const max_number_length = 2 // Scan the version number of VERSION-DIRECTIVE. // // Scope: // %YAML 1.1 # a comment \n // ^ // %YAML 1.1 # a comment \n // ^ func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool { // Repeat while the next character is digit. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } var value, length int8 for is_digit(parser.buffer, parser.buffer_pos) { // Check if the number is too long. length++ if length > max_number_length { return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", start_mark, "found extremely long version number") } value = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos)) skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Check if the number was present. if length == 0 { return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", start_mark, "did not find expected version number") } *number = value return true } // Scan the value of a TAG-DIRECTIVE token. // // Scope: // %TAG !yaml! tag:yaml.org,2002: \n // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // func yaml_parser_scan_tag_directive_value(parser *yaml_parser_t, start_mark yaml_mark_t, handle, prefix *[]byte) bool { var handle_value, prefix_value []byte // Eat whitespaces. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for is_blank(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Scan a handle. if !yaml_parser_scan_tag_handle(parser, true, start_mark, &handle_value) { return false } // Expect a whitespace. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } if !is_blank(parser.buffer, parser.buffer_pos) { yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", start_mark, "did not find expected whitespace") return false } // Eat whitespaces. for is_blank(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Scan a prefix. if !yaml_parser_scan_tag_uri(parser, true, nil, start_mark, &prefix_value) { return false } // Expect a whitespace or line break. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } if !is_blankz(parser.buffer, parser.buffer_pos) { yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive", start_mark, "did not find expected whitespace or line break") return false } *handle = handle_value *prefix = prefix_value return true } func yaml_parser_scan_anchor(parser *yaml_parser_t, token *yaml_token_t, typ yaml_token_type_t) bool { var s []byte // Eat the indicator character. start_mark := parser.mark skip(parser) // Consume the value. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for is_alpha(parser.buffer, parser.buffer_pos) { s = read(parser, s) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } end_mark := parser.mark /* * Check if length of the anchor is greater than 0 and it is followed by * a whitespace character or one of the indicators: * * '?', ':', ',', ']', '}', '%', '@', '`'. */ if len(s) == 0 || !(is_blankz(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '}' || parser.buffer[parser.buffer_pos] == '%' || parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '`') { context := "while scanning an alias" if typ == yaml_ANCHOR_TOKEN { context = "while scanning an anchor" } yaml_parser_set_scanner_error(parser, context, start_mark, "did not find expected alphabetic or numeric character") return false } // Create a token. *token = yaml_token_t{ typ: typ, start_mark: start_mark, end_mark: end_mark, value: s, } return true } /* * Scan a TAG token. */ func yaml_parser_scan_tag(parser *yaml_parser_t, token *yaml_token_t) bool { var handle, suffix []byte start_mark := parser.mark // Check if the tag is in the canonical form. if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } if parser.buffer[parser.buffer_pos+1] == '<' { // Keep the handle as '' // Eat '!<' skip(parser) skip(parser) // Consume the tag value. if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { return false } // Check for '>' and eat it. if parser.buffer[parser.buffer_pos] != '>' { yaml_parser_set_scanner_error(parser, "while scanning a tag", start_mark, "did not find the expected '>'") return false } skip(parser) } else { // The tag has either the '!suffix' or the '!handle!suffix' form. // First, try to scan a handle. if !yaml_parser_scan_tag_handle(parser, false, start_mark, &handle) { return false } // Check if it is, indeed, handle. if handle[0] == '!' && len(handle) > 1 && handle[len(handle)-1] == '!' { // Scan the suffix now. if !yaml_parser_scan_tag_uri(parser, false, nil, start_mark, &suffix) { return false } } else { // It wasn't a handle after all. Scan the rest of the tag. if !yaml_parser_scan_tag_uri(parser, false, handle, start_mark, &suffix) { return false } // Set the handle to '!'. handle = []byte{'!'} // A special case: the '!' tag. Set the handle to '' and the // suffix to '!'. if len(suffix) == 0 { handle, suffix = suffix, handle } } } // Check the character which ends the tag. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } if !is_blankz(parser.buffer, parser.buffer_pos) { yaml_parser_set_scanner_error(parser, "while scanning a tag", start_mark, "did not find expected whitespace or line break") return false } end_mark := parser.mark // Create a token. *token = yaml_token_t{ typ: yaml_TAG_TOKEN, start_mark: start_mark, end_mark: end_mark, value: handle, suffix: suffix, } return true } // Scan a tag handle. func yaml_parser_scan_tag_handle(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, handle *[]byte) bool { // Check the initial '!' character. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } if parser.buffer[parser.buffer_pos] != '!' { yaml_parser_set_scanner_tag_error(parser, directive, start_mark, "did not find expected '!'") return false } var s []byte // Copy the '!' character. s = read(parser, s) // Copy all subsequent alphabetical and numerical characters. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for is_alpha(parser.buffer, parser.buffer_pos) { s = read(parser, s) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Check if the trailing character is '!' and copy it. if parser.buffer[parser.buffer_pos] == '!' { s = read(parser, s) } else { // It's either the '!' tag or not really a tag handle. If it's a %TAG // directive, it's an error. If it's a tag token, it must be a part of URI. if directive && string(s) != "!" { yaml_parser_set_scanner_tag_error(parser, directive, start_mark, "did not find expected '!'") return false } } *handle = s return true } // Scan a tag. func yaml_parser_scan_tag_uri(parser *yaml_parser_t, directive bool, head []byte, start_mark yaml_mark_t, uri *[]byte) bool { //size_t length = head ? strlen((char *)head) : 0 var s []byte hasTag := len(head) > 0 // Copy the head if needed. // // Note that we don't copy the leading '!' character. if len(head) > 1 { s = append(s, head[1:]...) } // Scan the tag. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } // The set of characters that may appear in URI is as follows: // // '0'-'9', 'A'-'Z', 'a'-'z', '_', '-', ';', '/', '?', ':', '@', '&', // '=', '+', '$', ',', '.', '!', '~', '*', '\'', '(', ')', '[', ']', // '%'. // [Go] Convert this into more reasonable logic. for is_alpha(parser.buffer, parser.buffer_pos) || parser.buffer[parser.buffer_pos] == ';' || parser.buffer[parser.buffer_pos] == '/' || parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '@' || parser.buffer[parser.buffer_pos] == '&' || parser.buffer[parser.buffer_pos] == '=' || parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '$' || parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == '.' || parser.buffer[parser.buffer_pos] == '!' || parser.buffer[parser.buffer_pos] == '~' || parser.buffer[parser.buffer_pos] == '*' || parser.buffer[parser.buffer_pos] == '\'' || parser.buffer[parser.buffer_pos] == '(' || parser.buffer[parser.buffer_pos] == ')' || parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '%' { // Check if it is a URI-escape sequence. if parser.buffer[parser.buffer_pos] == '%' { if !yaml_parser_scan_uri_escapes(parser, directive, start_mark, &s) { return false } } else { s = read(parser, s) } if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } hasTag = true } if !hasTag { yaml_parser_set_scanner_tag_error(parser, directive, start_mark, "did not find expected tag URI") return false } *uri = s return true } // Decode an URI-escape sequence corresponding to a single UTF-8 character. func yaml_parser_scan_uri_escapes(parser *yaml_parser_t, directive bool, start_mark yaml_mark_t, s *[]byte) bool { // Decode the required number of characters. w := 1024 for w > 0 { // Check for a URI-escaped octet. if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { return false } if !(parser.buffer[parser.buffer_pos] == '%' && is_hex(parser.buffer, parser.buffer_pos+1) && is_hex(parser.buffer, parser.buffer_pos+2)) { return yaml_parser_set_scanner_tag_error(parser, directive, start_mark, "did not find URI escaped octet") } // Get the octet. octet := byte((as_hex(parser.buffer, parser.buffer_pos+1) << 4) + as_hex(parser.buffer, parser.buffer_pos+2)) // If it is the leading octet, determine the length of the UTF-8 sequence. if w == 1024 { w = width(octet) if w == 0 { return yaml_parser_set_scanner_tag_error(parser, directive, start_mark, "found an incorrect leading UTF-8 octet") } } else { // Check if the trailing octet is correct. if octet&0xC0 != 0x80 { return yaml_parser_set_scanner_tag_error(parser, directive, start_mark, "found an incorrect trailing UTF-8 octet") } } // Copy the octet and move the pointers. *s = append(*s, octet) skip(parser) skip(parser) skip(parser) w-- } return true } // Scan a block scalar. func yaml_parser_scan_block_scalar(parser *yaml_parser_t, token *yaml_token_t, literal bool) bool { // Eat the indicator '|' or '>'. start_mark := parser.mark skip(parser) // Scan the additional block scalar indicators. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } // Check for a chomping indicator. var chomping, increment int if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { // Set the chomping method and eat the indicator. if parser.buffer[parser.buffer_pos] == '+' { chomping = +1 } else { chomping = -1 } skip(parser) // Check for an indentation indicator. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } if is_digit(parser.buffer, parser.buffer_pos) { // Check that the indentation is greater than 0. if parser.buffer[parser.buffer_pos] == '0' { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", start_mark, "found an indentation indicator equal to 0") return false } // Get the indentation level and eat the indicator. increment = as_digit(parser.buffer, parser.buffer_pos) skip(parser) } } else if is_digit(parser.buffer, parser.buffer_pos) { // Do the same as above, but in the opposite order. if parser.buffer[parser.buffer_pos] == '0' { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", start_mark, "found an indentation indicator equal to 0") return false } increment = as_digit(parser.buffer, parser.buffer_pos) skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } if parser.buffer[parser.buffer_pos] == '+' || parser.buffer[parser.buffer_pos] == '-' { if parser.buffer[parser.buffer_pos] == '+' { chomping = +1 } else { chomping = -1 } skip(parser) } } // Eat whitespaces and comments to the end of the line. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for is_blank(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } if parser.buffer[parser.buffer_pos] == '#' { for !is_breakz(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } } // Check if we are at the end of the line. if !is_breakz(parser.buffer, parser.buffer_pos) { yaml_parser_set_scanner_error(parser, "while scanning a block scalar", start_mark, "did not find expected comment or line break") return false } // Eat a line break. if is_break(parser.buffer, parser.buffer_pos) { if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } skip_line(parser) } end_mark := parser.mark // Set the indentation level if it was specified. var indent int if increment > 0 { if parser.indent >= 0 { indent = parser.indent + increment } else { indent = increment } } // Scan the leading line breaks and determine the indentation level if needed. var s, leading_break, trailing_breaks []byte if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { return false } // Scan the block scalar content. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } var leading_blank, trailing_blank bool for parser.mark.column == indent && !is_z(parser.buffer, parser.buffer_pos) { // We are at the beginning of a non-empty line. // Is it a trailing whitespace? trailing_blank = is_blank(parser.buffer, parser.buffer_pos) // Check if we need to fold the leading line break. if !literal && !leading_blank && !trailing_blank && len(leading_break) > 0 && leading_break[0] == '\n' { // Do we need to join the lines by space? if len(trailing_breaks) == 0 { s = append(s, ' ') } } else { s = append(s, leading_break...) } leading_break = leading_break[:0] // Append the remaining line breaks. s = append(s, trailing_breaks...) trailing_breaks = trailing_breaks[:0] // Is it a leading whitespace? leading_blank = is_blank(parser.buffer, parser.buffer_pos) // Consume the current line. for !is_breakz(parser.buffer, parser.buffer_pos) { s = read(parser, s) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Consume the line break. if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } leading_break = read_line(parser, leading_break) // Eat the following indentation spaces and line breaks. if !yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks, start_mark, &end_mark) { return false } } // Chomp the tail. if chomping != -1 { s = append(s, leading_break...) } if chomping == 1 { s = append(s, trailing_breaks...) } // Create a token. *token = yaml_token_t{ typ: yaml_SCALAR_TOKEN, start_mark: start_mark, end_mark: end_mark, value: s, style: yaml_LITERAL_SCALAR_STYLE, } if !literal { token.style = yaml_FOLDED_SCALAR_STYLE } return true } // Scan indentation spaces and line breaks for a block scalar. Determine the // indentation level if needed. func yaml_parser_scan_block_scalar_breaks(parser *yaml_parser_t, indent *int, breaks *[]byte, start_mark yaml_mark_t, end_mark *yaml_mark_t) bool { *end_mark = parser.mark // Eat the indentation spaces and line breaks. max_indent := 0 for { // Eat the indentation spaces. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for (*indent == 0 || parser.mark.column < *indent) && is_space(parser.buffer, parser.buffer_pos) { skip(parser) if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } if parser.mark.column > max_indent { max_indent = parser.mark.column } // Check for a tab character messing the indentation. if (*indent == 0 || parser.mark.column < *indent) && is_tab(parser.buffer, parser.buffer_pos) { return yaml_parser_set_scanner_error(parser, "while scanning a block scalar", start_mark, "found a tab character where an indentation space is expected") } // Have we found a non-empty line? if !is_break(parser.buffer, parser.buffer_pos) { break } // Consume the line break. if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } // [Go] Should really be returning breaks instead. *breaks = read_line(parser, *breaks) *end_mark = parser.mark } // Determine the indentation level if needed. if *indent == 0 { *indent = max_indent if *indent < parser.indent+1 { *indent = parser.indent + 1 } if *indent < 1 { *indent = 1 } } return true } // Scan a quoted scalar. func yaml_parser_scan_flow_scalar(parser *yaml_parser_t, token *yaml_token_t, single bool) bool { // Eat the left quote. start_mark := parser.mark skip(parser) // Consume the content of the quoted scalar. var s, leading_break, trailing_breaks, whitespaces []byte for { // Check that there are no document indicators at the beginning of the line. if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { return false } if parser.mark.column == 0 && ((parser.buffer[parser.buffer_pos+0] == '-' && parser.buffer[parser.buffer_pos+1] == '-' && parser.buffer[parser.buffer_pos+2] == '-') || (parser.buffer[parser.buffer_pos+0] == '.' && parser.buffer[parser.buffer_pos+1] == '.' && parser.buffer[parser.buffer_pos+2] == '.')) && is_blankz(parser.buffer, parser.buffer_pos+3) { yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", start_mark, "found unexpected document indicator") return false } // Check for EOF. if is_z(parser.buffer, parser.buffer_pos) { yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar", start_mark, "found unexpected end of stream") return false } // Consume non-blank characters. leading_blanks := false for !is_blankz(parser.buffer, parser.buffer_pos) { if single && parser.buffer[parser.buffer_pos] == '\'' && parser.buffer[parser.buffer_pos+1] == '\'' { // Is is an escaped single quote. s = append(s, '\'') skip(parser) skip(parser) } else if single && parser.buffer[parser.buffer_pos] == '\'' { // It is a right single quote. break } else if !single && parser.buffer[parser.buffer_pos] == '"' { // It is a right double quote. break } else if !single && parser.buffer[parser.buffer_pos] == '\\' && is_break(parser.buffer, parser.buffer_pos+1) { // It is an escaped line break. if parser.unread < 3 && !yaml_parser_update_buffer(parser, 3) { return false } skip(parser) skip_line(parser) leading_blanks = true break } else if !single && parser.buffer[parser.buffer_pos] == '\\' { // It is an escape sequence. code_length := 0 // Check the escape character. switch parser.buffer[parser.buffer_pos+1] { case '0': s = append(s, 0) case 'a': s = append(s, '\x07') case 'b': s = append(s, '\x08') case 't', '\t': s = append(s, '\x09') case 'n': s = append(s, '\x0A') case 'v': s = append(s, '\x0B') case 'f': s = append(s, '\x0C') case 'r': s = append(s, '\x0D') case 'e': s = append(s, '\x1B') case ' ': s = append(s, '\x20') case '"': s = append(s, '"') case '\'': s = append(s, '\'') case '\\': s = append(s, '\\') case 'N': // NEL (#x85) s = append(s, '\xC2') s = append(s, '\x85') case '_': // #xA0 s = append(s, '\xC2') s = append(s, '\xA0') case 'L': // LS (#x2028) s = append(s, '\xE2') s = append(s, '\x80') s = append(s, '\xA8') case 'P': // PS (#x2029) s = append(s, '\xE2') s = append(s, '\x80') s = append(s, '\xA9') case 'x': code_length = 2 case 'u': code_length = 4 case 'U': code_length = 8 default: yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", start_mark, "found unknown escape character") return false } skip(parser) skip(parser) // Consume an arbitrary escape code. if code_length > 0 { var value int // Scan the character value. if parser.unread < code_length && !yaml_parser_update_buffer(parser, code_length) { return false } for k := 0; k < code_length; k++ { if !is_hex(parser.buffer, parser.buffer_pos+k) { yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", start_mark, "did not find expected hexdecimal number") return false } value = (value << 4) + as_hex(parser.buffer, parser.buffer_pos+k) } // Check the value and write the character. if (value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF { yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar", start_mark, "found invalid Unicode character escape code") return false } if value <= 0x7F { s = append(s, byte(value)) } else if value <= 0x7FF { s = append(s, byte(0xC0+(value>>6))) s = append(s, byte(0x80+(value&0x3F))) } else if value <= 0xFFFF { s = append(s, byte(0xE0+(value>>12))) s = append(s, byte(0x80+((value>>6)&0x3F))) s = append(s, byte(0x80+(value&0x3F))) } else { s = append(s, byte(0xF0+(value>>18))) s = append(s, byte(0x80+((value>>12)&0x3F))) s = append(s, byte(0x80+((value>>6)&0x3F))) s = append(s, byte(0x80+(value&0x3F))) } // Advance the pointer. for k := 0; k < code_length; k++ { skip(parser) } } } else { // It is a non-escaped non-blank character. s = read(parser, s) } if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } } // Check if we are at the end of the scalar. if single { if parser.buffer[parser.buffer_pos] == '\'' { break } } else { if parser.buffer[parser.buffer_pos] == '"' { break } } // Consume blank characters. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { if is_blank(parser.buffer, parser.buffer_pos) { // Consume a space or a tab character. if !leading_blanks { whitespaces = read(parser, whitespaces) } else { skip(parser) } } else { if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } // Check if it is a first line break. if !leading_blanks { whitespaces = whitespaces[:0] leading_break = read_line(parser, leading_break) leading_blanks = true } else { trailing_breaks = read_line(parser, trailing_breaks) } } if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Join the whitespaces or fold line breaks. if leading_blanks { // Do we need to fold line breaks? if len(leading_break) > 0 && leading_break[0] == '\n' { if len(trailing_breaks) == 0 { s = append(s, ' ') } else { s = append(s, trailing_breaks...) } } else { s = append(s, leading_break...) s = append(s, trailing_breaks...) } trailing_breaks = trailing_breaks[:0] leading_break = leading_break[:0] } else { s = append(s, whitespaces...) whitespaces = whitespaces[:0] } } // Eat the right quote. skip(parser) end_mark := parser.mark // Create a token. *token = yaml_token_t{ typ: yaml_SCALAR_TOKEN, start_mark: start_mark, end_mark: end_mark, value: s, style: yaml_SINGLE_QUOTED_SCALAR_STYLE, } if !single { token.style = yaml_DOUBLE_QUOTED_SCALAR_STYLE } return true } // Scan a plain scalar. func yaml_parser_scan_plain_scalar(parser *yaml_parser_t, token *yaml_token_t) bool { var s, leading_break, trailing_breaks, whitespaces []byte var leading_blanks bool var indent = parser.indent + 1 start_mark := parser.mark end_mark := parser.mark // Consume the content of the plain scalar. for { // Check for a document indicator. if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { return false } if parser.mark.column == 0 && ((parser.buffer[parser.buffer_pos+0] == '-' && parser.buffer[parser.buffer_pos+1] == '-' && parser.buffer[parser.buffer_pos+2] == '-') || (parser.buffer[parser.buffer_pos+0] == '.' && parser.buffer[parser.buffer_pos+1] == '.' && parser.buffer[parser.buffer_pos+2] == '.')) && is_blankz(parser.buffer, parser.buffer_pos+3) { break } // Check for a comment. if parser.buffer[parser.buffer_pos] == '#' { break } // Consume non-blank characters. for !is_blankz(parser.buffer, parser.buffer_pos) { // Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". if parser.flow_level > 0 && parser.buffer[parser.buffer_pos] == ':' && !is_blankz(parser.buffer, parser.buffer_pos+1) { yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", start_mark, "found unexpected ':'") return false } // Check for indicators that may end a plain scalar. if (parser.buffer[parser.buffer_pos] == ':' && is_blankz(parser.buffer, parser.buffer_pos+1)) || (parser.flow_level > 0 && (parser.buffer[parser.buffer_pos] == ',' || parser.buffer[parser.buffer_pos] == ':' || parser.buffer[parser.buffer_pos] == '?' || parser.buffer[parser.buffer_pos] == '[' || parser.buffer[parser.buffer_pos] == ']' || parser.buffer[parser.buffer_pos] == '{' || parser.buffer[parser.buffer_pos] == '}')) { break } // Check if we need to join whitespaces and breaks. if leading_blanks || len(whitespaces) > 0 { if leading_blanks { // Do we need to fold line breaks? if leading_break[0] == '\n' { if len(trailing_breaks) == 0 { s = append(s, ' ') } else { s = append(s, trailing_breaks...) } } else { s = append(s, leading_break...) s = append(s, trailing_breaks...) } trailing_breaks = trailing_breaks[:0] leading_break = leading_break[:0] leading_blanks = false } else { s = append(s, whitespaces...) whitespaces = whitespaces[:0] } } // Copy the character. s = read(parser, s) end_mark = parser.mark if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } } // Is it the end? if !(is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos)) { break } // Consume blank characters. if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } for is_blank(parser.buffer, parser.buffer_pos) || is_break(parser.buffer, parser.buffer_pos) { if is_blank(parser.buffer, parser.buffer_pos) { // Check for tab character that abuse indentation. if leading_blanks && parser.mark.column < indent && is_tab(parser.buffer, parser.buffer_pos) { yaml_parser_set_scanner_error(parser, "while scanning a plain scalar", start_mark, "found a tab character that violate indentation") return false } // Consume a space or a tab character. if !leading_blanks { whitespaces = read(parser, whitespaces) } else { skip(parser) } } else { if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) { return false } // Check if it is a first line break. if !leading_blanks { whitespaces = whitespaces[:0] leading_break = read_line(parser, leading_break) leading_blanks = true } else { trailing_breaks = read_line(parser, trailing_breaks) } } if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { return false } } // Check indentation level. if parser.flow_level == 0 && parser.mark.column < indent { break } } // Create a token. *token = yaml_token_t{ typ: yaml_SCALAR_TOKEN, start_mark: start_mark, end_mark: end_mark, value: s, style: yaml_PLAIN_SCALAR_STYLE, } // Note that we change the 'simple_key_allowed' flag. if leading_blanks { parser.simple_key_allowed = true } return true }
dep/vendor/gopkg.in/yaml.v2/scannerc.go/0
{ "file_path": "dep/vendor/gopkg.in/yaml.v2/scannerc.go", "repo_id": "dep", "token_count": 31788 }
49
{ "docs": { "Guides": ["introduction", "installation", "new-project", "migrating", "daily-dep", "uninstalling"], "References": ["ensure-mechanics", "failure-modes", "the-solver", "deduction", "Gopkg.toml", "Gopkg.lock", "FAQ", "env-vars", "glossary"] } }
dep/website/sidebars.json/0
{ "file_path": "dep/website/sidebars.json", "repo_id": "dep", "token_count": 110 }
50
# Go example projects [![Go Reference](https://pkg.go.dev/badge/golang.org/x/example.svg)](https://pkg.go.dev/golang.org/x/example) This repository contains a collection of Go programs and libraries that demonstrate the language, standard libraries, and tools. ## Clone the project ``` $ git clone https://go.googlesource.com/example $ cd example ``` https://go.googlesource.com/example is the canonical Git repository. It is mirrored at https://github.com/golang/example. ## [hello](hello/) and [hello/reverse](hello/reverse/) ``` $ cd hello $ go build $ ./hello -help ``` A trivial "Hello, world" program that uses a library package. The [hello](hello/) command covers: * The basic form of an executable command * Importing packages (from the standard library and the local repository) * Printing strings ([fmt](//golang.org/pkg/fmt/)) * Command-line flags ([flag](//golang.org/pkg/flag/)) * Logging ([log](//golang.org/pkg/log/)) The [reverse](hello/reverse/) reverse covers: * The basic form of a library * Conversion between string and []rune * Table-driven unit tests ([testing](//golang.org/pkg/testing/)) ## [helloserver](helloserver/) ``` $ cd helloserver $ go run . ``` A trivial "Hello, world" web server. Topics covered: * Command-line flags ([flag](//golang.org/pkg/flag/)) * Logging ([log](//golang.org/pkg/log/)) * Web servers ([net/http](//golang.org/pkg/net/http/)) ## [outyet](outyet/) ``` $ cd outyet $ go run . ``` A web server that answers the question: "Is Go 1.x out yet?" Topics covered: * Command-line flags ([flag](//golang.org/pkg/flag/)) * Web servers ([net/http](//golang.org/pkg/net/http/)) * HTML Templates ([html/template](//golang.org/pkg/html/template/)) * Logging ([log](//golang.org/pkg/log/)) * Long-running background processes * Synchronizing data access between goroutines ([sync](//golang.org/pkg/sync/)) * Exporting server state for monitoring ([expvar](//golang.org/pkg/expvar/)) * Unit and integration tests ([testing](//golang.org/pkg/testing/)) * Dependency injection * Time ([time](//golang.org/pkg/time/)) ## [appengine-hello](appengine-hello/) A trivial "Hello, world" App Engine application intended to be used as the starting point for your own code. Please see [Google App Engine SDK for Go](https://cloud.google.com/appengine/downloads#Google_App_Engine_SDK_for_Go) and [Quickstart for Go in the App Engine Standard Environment](https://cloud.google.com/appengine/docs/standard/go/quickstart). ## [gotypes](gotypes/) The `go/types` package is a type-checker for Go programs. It is one of the most complex packages in Go's standard library, so we have provided this tutorial to help you find your bearings. It comes with several example programs that you can obtain using `go get` and play with as you learn to build tools that analyze or manipulate Go programs. ## [template](template/) A trivial web server that demonstrates the use of the [`template` package](https://golang.org/pkg/text/template/)'s `block` feature. ## [slog-handler-guide](slog-handler-guide/) The `log/slog` package supports structured logging. It features a flexible backend in the form of a `Handler` interface. This guide can help you write your own handler.
example/README.md/0
{ "file_path": "example/README.md", "repo_id": "example", "token_count": 1015 }
51
// !+ package main import "fmt" func main() { fmt.Println("Hello, 世界") } //!-
example/gotypes/hello/hello.go/0
{ "file_path": "example/gotypes/hello/hello.go", "repo_id": "example", "token_count": 43 }
52
module golang.org/x/example/outyet go 1.19
example/outyet/go.mod/0
{ "file_path": "example/outyet/go.mod", "repo_id": "example", "token_count": 19 }
53
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>{{.Title}}</title> <style> body { font-family: sans-serif; } h1 { background: #ddd; } #sidebar { float: right; } </style> </head> <body> <h1>{{.Title}}</h1> <div id="sidebar"> {{block "sidebar" .}} <h2>Links</h2> {{/* The dashes in the following template directives ensure the generated HTML of this list contains no extraneous spaces or line breaks. */}} <ul> {{- range .Links}} <li><a href="{{.URL}}">{{.Title}}</a></li> {{- end}} </ul> {{end}} </div> {{block "content" .}} <div id="content"> {{.Body}} </div> {{end}} </body> </html>
example/template/index.tmpl/0
{ "file_path": "example/template/index.tmpl", "repo_id": "example", "token_count": 353 }
54
package glog import ( "flag" "io/ioutil" "runtime" "sync" "sync/atomic" "testing" "time" ) // discarder is a flushSyncWriter that discards all data. // Sync sleeps for 10ms to simulate a disk seek. type discarder struct { } func (d *discarder) Write(data []byte) (int, error) { return len(data), nil } func (d *discarder) Flush() error { return nil } func (d *discarder) Sync() error { time.Sleep(10 * time.Millisecond) return nil } func (d *discarder) filenames() []string { return nil } // newDiscard sets the log writers to all new byte buffers and returns the old array. func (s *fileSink) newDiscarders() severityWriters { return s.swap(severityWriters{new(discarder), new(discarder), new(discarder), new(discarder)}) } func discardStderr() func() { se := sinks.stderr.w sinks.stderr.w = ioutil.Discard return func() { sinks.stderr.w = se } } const message = "benchmark log message" func benchmarkLog(b *testing.B, log func(...any)) { defer sinks.file.swap(sinks.file.newDiscarders()) defer discardStderr()() b.ResetTimer() for i := 0; i < b.N; i++ { log(message) } b.StopTimer() } func benchmarkLogConcurrent(b *testing.B, log func(...any)) { defer sinks.file.swap(sinks.file.newDiscarders()) defer discardStderr()() b.ResetTimer() concurrency := runtime.GOMAXPROCS(0) var wg sync.WaitGroup wg.Add(concurrency) for i := 0; i < concurrency; i++ { go func() { for i := 0; i < b.N; i++ { log(message) } wg.Done() }() } wg.Wait() b.StopTimer() } func BenchmarkInfo(b *testing.B) { benchmarkLog(b, Info) } func BenchmarkInfoConcurrent(b *testing.B) { benchmarkLogConcurrent(b, Info) } func BenchmarkWarning(b *testing.B) { benchmarkLog(b, Warning) } func BenchmarkWarningConcurrent(b *testing.B) { benchmarkLogConcurrent(b, Warning) } func BenchmarkError(b *testing.B) { benchmarkLog(b, Error) } func BenchmarkErrorConcurrent(b *testing.B) { benchmarkLogConcurrent(b, Error) } func mixer() func(...any) { var i int64 return func(args ...any) { n := atomic.AddInt64(&i, 1) switch { case n%10000 == 0: Error(args...) case n%1000 == 0: Warning(args...) default: Info(args...) } } } func BenchmarkMix(b *testing.B) { benchmarkLog(b, mixer()) } func BenchmarkMixConcurrent(b *testing.B) { benchmarkLogConcurrent(b, mixer()) } func BenchmarkVLogDisabled(b *testing.B) { benchmarkLog(b, vlog) } func BenchmarkVLogDisabledConcurrent(b *testing.B) { benchmarkLogConcurrent(b, vlog) } func BenchmarkVLogModuleFlagSet(b *testing.B) { defer withVmodule("nonexistant=5")() benchmarkLog(b, vlog) } func BenchmarkVLogModuleFlagSetConcurrent(b *testing.B) { defer withVmodule("nonexistant=5")() benchmarkLogConcurrent(b, vlog) } func BenchmarkVLogEnabled(b *testing.B) { defer withVmodule("glog_bench_test=5")() if got := bool(V(3)); got != true { b.Fatalf("V(3) == %v, want %v", got, true) } benchmarkLog(b, vlog) } func BenchmarkVLogEnabledConcurrent(b *testing.B) { defer withVmodule("glog_bench_test=5")() benchmarkLogConcurrent(b, vlog) } func vlog(args ...any) { V(3).Info(args) } func withVmodule(val string) func() { if err := flag.Set("vmodule", val); err != nil { panic(err) } return func() { flag.Set("vmodule", "") } }
glog/glog_bench_test.go/0
{ "file_path": "glog/glog_bench_test.go", "repo_id": "glog", "token_count": 1331 }
55
// Copyright 2023 Google Inc. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Package stackdump provides wrappers for runtime.Stack and runtime.Callers // with uniform support for skipping caller frames. // // ⚠ Unlike the functions in the runtime package, these may allocate a // non-trivial quantity of memory: use them with care. ⚠ package stackdump import ( "bytes" "runtime" ) // runtimeStackSelfFrames is 1 if runtime.Stack includes the call to // runtime.Stack itself or 0 if it does not. // // As of 2016-04-27, the gccgo compiler includes runtime.Stack but the gc // compiler does not. var runtimeStackSelfFrames = func() int { for n := 1 << 10; n < 1<<20; n *= 2 { buf := make([]byte, n) n := runtime.Stack(buf, false) if bytes.Contains(buf[:n], []byte("runtime.Stack")) { return 1 } else if n < len(buf) || bytes.Count(buf, []byte("\n")) >= 3 { return 0 } } return 0 }() // Stack is a stack dump for a single goroutine. type Stack struct { // Text is a representation of the stack dump in a human-readable format. Text []byte // PC is a representation of the stack dump using raw program counter values. PC []uintptr } func (s Stack) String() string { return string(s.Text) } // Caller returns the Stack dump for the calling goroutine, starting skipDepth // frames before the caller of Caller. (Caller(0) provides a dump starting at // the caller of this function.) func Caller(skipDepth int) Stack { return Stack{ Text: CallerText(skipDepth + 1), PC: CallerPC(skipDepth + 1), } } // CallerText returns a textual dump of the stack starting skipDepth frames before // the caller. (CallerText(0) provides a dump starting at the caller of this // function.) func CallerText(skipDepth int) []byte { for n := 1 << 10; ; n *= 2 { buf := make([]byte, n) n := runtime.Stack(buf, false) if n < len(buf) { return pruneFrames(skipDepth+1+runtimeStackSelfFrames, buf[:n]) } } } // CallerPC returns a dump of the program counters of the stack starting // skipDepth frames before the caller. (CallerPC(0) provides a dump starting at // the caller of this function.) func CallerPC(skipDepth int) []uintptr { for n := 1 << 8; ; n *= 2 { buf := make([]uintptr, n) n := runtime.Callers(skipDepth+2, buf) if n < len(buf) { return buf[:n] } } } // pruneFrames removes the topmost skipDepth frames of the first goroutine in a // textual stack dump. It overwrites the passed-in slice. // // If there are fewer than skipDepth frames in the first goroutine's stack, // pruneFrames prunes it to an empty stack and leaves the remaining contents // intact. func pruneFrames(skipDepth int, stack []byte) []byte { headerLen := 0 for i, c := range stack { if c == '\n' { headerLen = i + 1 break } } if headerLen == 0 { return stack // No header line - not a well-formed stack trace. } skipLen := headerLen skipNewlines := skipDepth * 2 for ; skipLen < len(stack) && skipNewlines > 0; skipLen++ { c := stack[skipLen] if c != '\n' { continue } skipNewlines-- skipLen++ if skipNewlines == 0 || skipLen == len(stack) || stack[skipLen] == '\n' { break } } pruned := stack[skipLen-headerLen:] copy(pruned, stack[:headerLen]) return pruned }
glog/internal/stackdump/stackdump.go/0
{ "file_path": "glog/internal/stackdump/stackdump.go", "repo_id": "glog", "token_count": 1213 }
56
## Tools {#tools} ### Go command {#go-command} ### Cgo {#cgo}
go/doc/initial/3-tools.md/0
{ "file_path": "go/doc/initial/3-tools.md", "repo_id": "go", "token_count": 28 }
57
# This file contains the initial defaults for go command configuration. # Values set by 'go env -w' and written to the user's go/env file override these. # The environment overrides everything else. # Use the Go module mirror and checksum database by default. # See https://proxy.golang.org for details. GOPROXY=https://proxy.golang.org,direct GOSUMDB=sum.golang.org # Automatically download newer toolchains as directed by go.mod files. # See https://go.dev/doc/toolchain for details. GOTOOLCHAIN=auto
go/go.env/0
{ "file_path": "go/go.env", "repo_id": "go", "token_count": 146 }
58
For information about plugins and other support for Go in editors and shells, see this page on the Go Wiki: https://golang.org/wiki/IDEsAndTextEditorPlugins
go/misc/editors/0
{ "file_path": "go/misc/editors", "repo_id": "go", "token_count": 43 }
59
Vendoring in std and cmd ======================== The Go command maintains copies of external packages needed by the standard library in the src/vendor and src/cmd/vendor directories. There are two modules, std and cmd, defined in src/go.mod and src/cmd/go.mod. When a package outside std or cmd is imported by a package inside std or cmd, the import path is interpreted as if it had a "vendor/" prefix. For example, within "crypto/tls", an import of "golang.org/x/crypto/cryptobyte" resolves to "vendor/golang.org/x/crypto/cryptobyte". When a package with the same path is imported from a package outside std or cmd, it will be resolved normally. Consequently, a binary may be built with two copies of a package at different versions if the package is imported normally and vendored by the standard library. Vendored packages are internally renamed with a "vendor/" prefix to preserve the invariant that all packages have distinct paths. This is necessary to avoid compiler and linker conflicts. Adding a "vendor/" prefix also maintains the invariant that standard library packages begin with a dotless path element. The module requirements of std and cmd do not influence version selection in other modules. They are only considered when running module commands like 'go get' and 'go mod vendor' from a directory in GOROOT/src. Maintaining vendor directories ============================== Before updating vendor directories, ensure that module mode is enabled. Make sure that GO111MODULE is not set in the environment, or that it is set to 'on' or 'auto', and if you use a go.work file, set GOWORK=off. Requirements may be added, updated, and removed with 'go get'. The vendor directory may be updated with 'go mod vendor'. A typical sequence might be: cd src # or src/cmd go get golang.org/x/net@master go mod tidy go mod vendor Use caution when passing '-u' to 'go get'. The '-u' flag updates modules providing all transitively imported packages, not only the module providing the target package. Note that 'go mod vendor' only copies packages that are transitively imported by packages in the current module. If a new package is needed, it should be imported before running 'go mod vendor'.
go/src/README.vendor/0
{ "file_path": "go/src/README.vendor", "repo_id": "go", "token_count": 572 }
60
// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package zip import ( "bytes" "io" "os" "path/filepath" "testing" ) func FuzzReader(f *testing.F) { testdata, err := os.ReadDir("testdata") if err != nil { f.Fatalf("failed to read testdata directory: %s", err) } for _, de := range testdata { if de.IsDir() { continue } b, err := os.ReadFile(filepath.Join("testdata", de.Name())) if err != nil { f.Fatalf("failed to read testdata: %s", err) } f.Add(b) } f.Fuzz(func(t *testing.T, b []byte) { r, err := NewReader(bytes.NewReader(b), int64(len(b))) if err != nil { return } type file struct { header *FileHeader content []byte } files := []file{} for _, f := range r.File { fr, err := f.Open() if err != nil { continue } content, err := io.ReadAll(fr) if err != nil { continue } files = append(files, file{header: &f.FileHeader, content: content}) if _, err := r.Open(f.Name); err != nil { continue } } // If we were unable to read anything out of the archive don't // bother trying to roundtrip it. if len(files) == 0 { return } w := NewWriter(io.Discard) for _, f := range files { ww, err := w.CreateHeader(f.header) if err != nil { t.Fatalf("unable to write previously parsed header: %s", err) } if _, err := ww.Write(f.content); err != nil { t.Fatalf("unable to write previously parsed content: %s", err) } } if err := w.Close(); err != nil { t.Fatalf("Unable to write archive: %s", err) } // TODO: We may want to check if the archive roundtrips. }) }
go/src/archive/zip/fuzz_test.go/0
{ "file_path": "go/src/archive/zip/fuzz_test.go", "repo_id": "go", "token_count": 715 }
61
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package bufio import ( "bytes" "errors" "io" "unicode/utf8" ) // Scanner provides a convenient interface for reading data such as // a file of newline-delimited lines of text. Successive calls to // the [Scanner.Scan] method will step through the 'tokens' of a file, skipping // the bytes between the tokens. The specification of a token is // defined by a split function of type [SplitFunc]; the default split // function breaks the input into lines with line termination stripped. [Scanner.Split] // functions are defined in this package for scanning a file into // lines, bytes, UTF-8-encoded runes, and space-delimited words. The // client may instead provide a custom split function. // // Scanning stops unrecoverably at EOF, the first I/O error, or a token too // large to fit in the [Scanner.Buffer]. When a scan stops, the reader may have // advanced arbitrarily far past the last token. Programs that need more // control over error handling or large tokens, or must run sequential scans // on a reader, should use [bufio.Reader] instead. type Scanner struct { r io.Reader // The reader provided by the client. split SplitFunc // The function to split the tokens. maxTokenSize int // Maximum size of a token; modified by tests. token []byte // Last token returned by split. buf []byte // Buffer used as argument to split. start int // First non-processed byte in buf. end int // End of data in buf. err error // Sticky error. empties int // Count of successive empty tokens. scanCalled bool // Scan has been called; buffer is in use. done bool // Scan has finished. } // SplitFunc is the signature of the split function used to tokenize the // input. The arguments are an initial substring of the remaining unprocessed // data and a flag, atEOF, that reports whether the [Reader] has no more data // to give. The return values are the number of bytes to advance the input // and the next token to return to the user, if any, plus an error, if any. // // Scanning stops if the function returns an error, in which case some of // the input may be discarded. If that error is [ErrFinalToken], scanning // stops with no error. A non-nil token delivered with [ErrFinalToken] // will be the last token, and a nil token with [ErrFinalToken] // immediately stops the scanning. // // Otherwise, the [Scanner] advances the input. If the token is not nil, // the [Scanner] returns it to the user. If the token is nil, the // Scanner reads more data and continues scanning; if there is no more // data--if atEOF was true--the [Scanner] returns. If the data does not // yet hold a complete token, for instance if it has no newline while // scanning lines, a [SplitFunc] can return (0, nil, nil) to signal the // [Scanner] to read more data into the slice and try again with a // longer slice starting at the same point in the input. // // The function is never called with an empty data slice unless atEOF // is true. If atEOF is true, however, data may be non-empty and, // as always, holds unprocessed text. type SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error) // Errors returned by Scanner. var ( ErrTooLong = errors.New("bufio.Scanner: token too long") ErrNegativeAdvance = errors.New("bufio.Scanner: SplitFunc returns negative advance count") ErrAdvanceTooFar = errors.New("bufio.Scanner: SplitFunc returns advance count beyond input") ErrBadReadCount = errors.New("bufio.Scanner: Read returned impossible count") ) const ( // MaxScanTokenSize is the maximum size used to buffer a token // unless the user provides an explicit buffer with [Scanner.Buffer]. // The actual maximum token size may be smaller as the buffer // may need to include, for instance, a newline. MaxScanTokenSize = 64 * 1024 startBufSize = 4096 // Size of initial allocation for buffer. ) // NewScanner returns a new [Scanner] to read from r. // The split function defaults to [ScanLines]. func NewScanner(r io.Reader) *Scanner { return &Scanner{ r: r, split: ScanLines, maxTokenSize: MaxScanTokenSize, } } // Err returns the first non-EOF error that was encountered by the [Scanner]. func (s *Scanner) Err() error { if s.err == io.EOF { return nil } return s.err } // Bytes returns the most recent token generated by a call to [Scanner.Scan]. // The underlying array may point to data that will be overwritten // by a subsequent call to Scan. It does no allocation. func (s *Scanner) Bytes() []byte { return s.token } // Text returns the most recent token generated by a call to [Scanner.Scan] // as a newly allocated string holding its bytes. func (s *Scanner) Text() string { return string(s.token) } // ErrFinalToken is a special sentinel error value. It is intended to be // returned by a Split function to indicate that the scanning should stop // with no error. If the token being delivered with this error is not nil, // the token is the last token. // // The value is useful to stop processing early or when it is necessary to // deliver a final empty token (which is different from a nil token). // One could achieve the same behavior with a custom error value but // providing one here is tidier. // See the emptyFinalToken example for a use of this value. var ErrFinalToken = errors.New("final token") // Scan advances the [Scanner] to the next token, which will then be // available through the [Scanner.Bytes] or [Scanner.Text] method. It returns false when // there are no more tokens, either by reaching the end of the input or an error. // After Scan returns false, the [Scanner.Err] method will return any error that // occurred during scanning, except that if it was [io.EOF], [Scanner.Err] // will return nil. // Scan panics if the split function returns too many empty // tokens without advancing the input. This is a common error mode for // scanners. func (s *Scanner) Scan() bool { if s.done { return false } s.scanCalled = true // Loop until we have a token. for { // See if we can get a token with what we already have. // If we've run out of data but have an error, give the split function // a chance to recover any remaining, possibly empty token. if s.end > s.start || s.err != nil { advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil) if err != nil { if err == ErrFinalToken { s.token = token s.done = true // When token is not nil, it means the scanning stops // with a trailing token, and thus the return value // should be true to indicate the existence of the token. return token != nil } s.setErr(err) return false } if !s.advance(advance) { return false } s.token = token if token != nil { if s.err == nil || advance > 0 { s.empties = 0 } else { // Returning tokens not advancing input at EOF. s.empties++ if s.empties > maxConsecutiveEmptyReads { panic("bufio.Scan: too many empty tokens without progressing") } } return true } } // We cannot generate a token with what we are holding. // If we've already hit EOF or an I/O error, we are done. if s.err != nil { // Shut it down. s.start = 0 s.end = 0 return false } // Must read more data. // First, shift data to beginning of buffer if there's lots of empty space // or space is needed. if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf)/2) { copy(s.buf, s.buf[s.start:s.end]) s.end -= s.start s.start = 0 } // Is the buffer full? If so, resize. if s.end == len(s.buf) { // Guarantee no overflow in the multiplication below. const maxInt = int(^uint(0) >> 1) if len(s.buf) >= s.maxTokenSize || len(s.buf) > maxInt/2 { s.setErr(ErrTooLong) return false } newSize := len(s.buf) * 2 if newSize == 0 { newSize = startBufSize } newSize = min(newSize, s.maxTokenSize) newBuf := make([]byte, newSize) copy(newBuf, s.buf[s.start:s.end]) s.buf = newBuf s.end -= s.start s.start = 0 } // Finally we can read some input. Make sure we don't get stuck with // a misbehaving Reader. Officially we don't need to do this, but let's // be extra careful: Scanner is for safe, simple jobs. for loop := 0; ; { n, err := s.r.Read(s.buf[s.end:len(s.buf)]) if n < 0 || len(s.buf)-s.end < n { s.setErr(ErrBadReadCount) break } s.end += n if err != nil { s.setErr(err) break } if n > 0 { s.empties = 0 break } loop++ if loop > maxConsecutiveEmptyReads { s.setErr(io.ErrNoProgress) break } } } } // advance consumes n bytes of the buffer. It reports whether the advance was legal. func (s *Scanner) advance(n int) bool { if n < 0 { s.setErr(ErrNegativeAdvance) return false } if n > s.end-s.start { s.setErr(ErrAdvanceTooFar) return false } s.start += n return true } // setErr records the first error encountered. func (s *Scanner) setErr(err error) { if s.err == nil || s.err == io.EOF { s.err = err } } // Buffer sets the initial buffer to use when scanning // and the maximum size of buffer that may be allocated during scanning. // The maximum token size must be less than the larger of max and cap(buf). // If max <= cap(buf), [Scanner.Scan] will use this buffer only and do no allocation. // // By default, [Scanner.Scan] uses an internal buffer and sets the // maximum token size to [MaxScanTokenSize]. // // Buffer panics if it is called after scanning has started. func (s *Scanner) Buffer(buf []byte, max int) { if s.scanCalled { panic("Buffer called after Scan") } s.buf = buf[0:cap(buf)] s.maxTokenSize = max } // Split sets the split function for the [Scanner]. // The default split function is [ScanLines]. // // Split panics if it is called after scanning has started. func (s *Scanner) Split(split SplitFunc) { if s.scanCalled { panic("Split called after Scan") } s.split = split } // Split functions // ScanBytes is a split function for a [Scanner] that returns each byte as a token. func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } return 1, data[0:1], nil } var errorRune = []byte(string(utf8.RuneError)) // ScanRunes is a split function for a [Scanner] that returns each // UTF-8-encoded rune as a token. The sequence of runes returned is // equivalent to that from a range loop over the input as a string, which // means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd". // Because of the Scan interface, this makes it impossible for the client to // distinguish correctly encoded replacement runes from encoding errors. func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } // Fast path 1: ASCII. if data[0] < utf8.RuneSelf { return 1, data[0:1], nil } // Fast path 2: Correct UTF-8 decode without error. _, width := utf8.DecodeRune(data) if width > 1 { // It's a valid encoding. Width cannot be one for a correctly encoded // non-ASCII rune. return width, data[0:width], nil } // We know it's an error: we have width==1 and implicitly r==utf8.RuneError. // Is the error because there wasn't a full rune to be decoded? // FullRune distinguishes correctly between erroneous and incomplete encodings. if !atEOF && !utf8.FullRune(data) { // Incomplete; get more bytes. return 0, nil, nil } // We have a real UTF-8 encoding error. Return a properly encoded error rune // but advance only one byte. This matches the behavior of a range loop over // an incorrectly encoded string. return 1, errorRune, nil } // dropCR drops a terminal \r from the data. func dropCR(data []byte) []byte { if len(data) > 0 && data[len(data)-1] == '\r' { return data[0 : len(data)-1] } return data } // ScanLines is a split function for a [Scanner] that returns each line of // text, stripped of any trailing end-of-line marker. The returned line may // be empty. The end-of-line marker is one optional carriage return followed // by one mandatory newline. In regular expression notation, it is `\r?\n`. // The last non-empty line of input will be returned even if it has no // newline. func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) { if atEOF && len(data) == 0 { return 0, nil, nil } if i := bytes.IndexByte(data, '\n'); i >= 0 { // We have a full newline-terminated line. return i + 1, dropCR(data[0:i]), nil } // If we're at EOF, we have a final, non-terminated line. Return it. if atEOF { return len(data), dropCR(data), nil } // Request more data. return 0, nil, nil } // isSpace reports whether the character is a Unicode white space character. // We avoid dependency on the unicode package, but check validity of the implementation // in the tests. func isSpace(r rune) bool { if r <= '\u00FF' { // Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs. switch r { case ' ', '\t', '\n', '\v', '\f', '\r': return true case '\u0085', '\u00A0': return true } return false } // High-valued ones. if '\u2000' <= r && r <= '\u200a' { return true } switch r { case '\u1680', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000': return true } return false } // ScanWords is a split function for a [Scanner] that returns each // space-separated word of text, with surrounding spaces deleted. It will // never return an empty string. The definition of space is set by // unicode.IsSpace. func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) { // Skip leading spaces. start := 0 for width := 0; start < len(data); start += width { var r rune r, width = utf8.DecodeRune(data[start:]) if !isSpace(r) { break } } // Scan until space, marking end of word. for width, i := 0, start; i < len(data); i += width { var r rune r, width = utf8.DecodeRune(data[i:]) if isSpace(r) { return i + width, data[start:i], nil } } // If we're at EOF, we have a final, non-empty, non-terminated word. Return it. if atEOF && len(data) > start { return len(data), data[start:], nil } // Request more data. return start, nil, nil }
go/src/bufio/scan.go/0
{ "file_path": "go/src/bufio/scan.go", "repo_id": "go", "token_count": 4945 }
62
:: Copyright 2012 The Go Authors. All rights reserved. :: Use of this source code is governed by a BSD-style :: license that can be found in the LICENSE file. @echo off setlocal set GOBUILDFAIL=0 go tool dist env -w -p >env.bat if errorlevel 1 goto fail call .\env.bat del env.bat echo. if exist %GOTOOLDIR%\dist.exe goto distok echo cannot find %GOTOOLDIR%\dist; nothing to clean goto fail :distok "%GOBIN%\go" clean -i std "%GOBIN%\go" tool dist clean "%GOBIN%\go" clean -i cmd goto end :fail set GOBUILDFAIL=1 :end if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
go/src/clean.bat/0
{ "file_path": "go/src/clean.bat", "repo_id": "go", "token_count": 225 }
63
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This file encapsulates some of the odd characteristics of the // s390x instruction set, to minimize its interaction // with the core of the assembler. package arch import ( "cmd/internal/obj/s390x" ) func jumpS390x(word string) bool { switch word { case "BRC", "BC", "BCL", "BEQ", "BGE", "BGT", "BL", "BLE", "BLEU", "BLT", "BLTU", "BNE", "BR", "BVC", "BVS", "BRCT", "BRCTG", "CMPBEQ", "CMPBGE", "CMPBGT", "CMPBLE", "CMPBLT", "CMPBNE", "CMPUBEQ", "CMPUBGE", "CMPUBGT", "CMPUBLE", "CMPUBLT", "CMPUBNE", "CRJ", "CGRJ", "CLRJ", "CLGRJ", "CIJ", "CGIJ", "CLIJ", "CLGIJ", "CALL", "JMP": return true } return false } func s390xRegisterNumber(name string, n int16) (int16, bool) { switch name { case "AR": if 0 <= n && n <= 15 { return s390x.REG_AR0 + n, true } case "F": if 0 <= n && n <= 15 { return s390x.REG_F0 + n, true } case "R": if 0 <= n && n <= 15 { return s390x.REG_R0 + n, true } case "V": if 0 <= n && n <= 31 { return s390x.REG_V0 + n, true } } return 0, false }
go/src/cmd/asm/internal/arch/s390x.go/0
{ "file_path": "go/src/cmd/asm/internal/arch/s390x.go", "repo_id": "go", "token_count": 624 }
64
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This input was created by taking the instruction productions in // the old assembler's (7a's) grammar and hand-writing complete // instructions for each rule, to guarantee we cover the same space. #include "../../../../../runtime/textflag.h" TEXT foo(SB), DUPOK|NOSPLIT, $-8 // arithmetic operations ADDW $1, R2, R3 ADDW R1, R2, R3 ADDW R1, ZR, R3 ADD $1, R2, R3 ADD R1, R2, R3 ADD R1, ZR, R3 ADD $1, R2, R3 ADDW $1, R2 ADDW R1, R2 ADD $1, R2 ADD R1, R2 ADD R1>>11, R2 ADD R1<<22, R2 ADD R1->33, R2 ADD $0x000aaa, R2, R3 // ADD $2730, R2, R3 // 43a82a91 ADD $0x000aaa, R2 // ADD $2730, R2 // 42a82a91 ADD $0xaaa000, R2, R3 // ADD $11182080, R2, R3 // 43a86a91 ADD $0xaaa000, R2 // ADD $11182080, R2 // 42a86a91 ADD $0xaaaaaa, R2, R3 // ADD $11184810, R2, R3 // 43a82a9163a86a91 ADD $0xaaaaaa, R2 // ADD $11184810, R2 // 42a82a9142a86a91 SUB $0x000aaa, R2, R3 // SUB $2730, R2, R3 // 43a82ad1 SUB $0x000aaa, R2 // SUB $2730, R2 // 42a82ad1 SUB $0xaaa000, R2, R3 // SUB $11182080, R2, R3 // 43a86ad1 SUB $0xaaa000, R2 // SUB $11182080, R2 // 42a86ad1 SUB $0xaaaaaa, R2, R3 // SUB $11184810, R2, R3 // 43a82ad163a86ad1 SUB $0xaaaaaa, R2 // SUB $11184810, R2 // 42a82ad142a86ad1 ADDW $0x60060, R2 // ADDW $393312, R2 // 4280011142804111 ADD $0x186a0, R2, R5 // ADD $100000, R2, R5 // 45801a91a5604091 SUB $0xe7791f700, R3, R1 // SUB $62135596800, R3, R1 // 1be09ed23bf2aef2db01c0f261001bcb ADD $0x3fffffffc000, R5 // ADD $70368744161280, R5 // fb7f72b2a5001b8b ADD R1>>11, R2, R3 ADD R1<<22, R2, R3 ADD R1->33, R2, R3 AND R1@>33, R2, R3 ADD R1.UXTB, R2, R3 // 4300218b ADD R1.UXTB<<4, R2, R3 // 4310218b ADD R2, RSP, RSP // ff63228b ADD R2.SXTX<<1, RSP, RSP // ffe7228b ADD ZR.SXTX<<1, R2, R3 // 43e43f8b ADDW R2.SXTW, R10, R12 // 4cc1220b ADD R19.UXTX, R14, R17 // d161338b ADDSW R19.UXTW, R14, R17 // d141332b ADDS R12.SXTX, R3, R1 // 61e02cab SUB R19.UXTH<<4, R2, R21 // 553033cb SUBW R1.UXTX<<1, R3, R2 // 6264214b SUBS R3.UXTX, R8, R9 // 096123eb SUBSW R17.UXTH, R15, R21 // f521316b SUBW ZR<<14, R19, R13 // 6d3a1f4b CMP R2.SXTH, R13 // bfa122eb CMN R1.SXTX<<2, R10 // 5fe921ab CMPW R2.UXTH<<3, R11 // 7f2d226b CMNW R1.SXTB, R9 // 3f81212b ADD R1<<1, RSP, R3 // e367218b ADDW R1<<2, R3, RSP // 7f48210b SUB R1<<3, RSP // ff6f21cb SUBS R1<<4, RSP, R3 // e37321eb ADDS R1<<1, RSP, R4 // e46721ab CMP R1<<2, RSP // ff6b21eb CMN R1<<3, RSP // ff6f21ab ADDS R1<<1, ZR, R4 // e40701ab ADD R3<<50, ZR, ZR // ffcb038b CMP R4<<24, ZR // ff6304eb CMPW $0x60060, R2 // CMPW $393312, R2 // 1b0c8052db00a0725f001b6b CMPW $40960, R0 // 1f284071 CMPW $27745, R2 // 3b8c8d525f001b6b CMNW $0x3fffffc0, R2 // CMNW $1073741760, R2 // fb5f1a325f001b2b CMPW $0xffff0, R1 // CMPW $1048560, R1 // fb3f1c323f001b6b CMP $0xffffffffffa0, R3 // CMP $281474976710560, R3 // fb0b80921b00e0f27f001beb CMP $0xf4240, R1 // CMP $1000000, R1 // 1b4888d2fb01a0f23f001beb CMP $3343198598084851058, R3 // 5bae8ed2db8daef23badcdf2bbcce5f27f001beb CMP $3, R2 CMP R1, R2 CMP R1->11, R2 CMP R1>>22, R2 CMP R1<<33, R2 CMP R22.SXTX, RSP // ffe336eb CMP $0x22220000, RSP // CMP $572653568, RSP // 5b44a4d2ff633beb CMPW $0x22220000, RSP // CMPW $572653568, RSP // 5b44a452ff433b6b CCMN MI, ZR, R1, $4 // e44341ba // MADD Rn,Rm,Ra,Rd MADD R1, R2, R3, R4 // 6408019b // CLS CLSW R1, R2 CLS R1, R2 SBC $0, R1 // 21001fda SBCW $0, R1 // 21001f5a SBCS $0, R1 // 21001ffa SBCSW $0, R1 // 21001f7a ADC $0, R1 // 21001f9a ADCW $0, R1 // 21001f1a ADCS $0, R1 // 21001fba ADCSW $0, R1 // 21001f3a // fp/simd instructions. VADDP V1.B16, V2.B16, V3.B16 // 43bc214e VADDP V1.S4, V2.S4, V3.S4 // 43bca14e VADDP V1.D2, V2.D2, V3.D2 // 43bce14e VAND V21.B8, V12.B8, V3.B8 // 831d350e VCMEQ V1.H4, V2.H4, V3.H4 // 438c612e VORR V5.B16, V4.B16, V3.B16 // 831ca54e VADD V16.S4, V5.S4, V9.S4 // a984b04e VEOR V0.B16, V1.B16, V0.B16 // 201c206e VADDV V0.S4, V0 // 00b8b14e VMOVI $82, V0.B16 // 40e6024f VUADDLV V6.B16, V6 // c638306e VADD V1, V2, V3 // 4384e15e VADD V1, V3, V3 // 6384e15e VSUB V12, V30, V30 // de87ec7e VSUB V12, V20, V30 // 9e86ec7e VFMLA V1.D2, V12.D2, V1.D2 // 81cd614e VFMLA V1.S2, V12.S2, V1.S2 // 81cd210e VFMLA V1.S4, V12.S4, V1.S4 // 81cd214e VFMLS V1.D2, V12.D2, V1.D2 // 81cde14e VFMLS V1.S2, V12.S2, V1.S2 // 81cda10e VFMLS V1.S4, V12.S4, V1.S4 // 81cda14e VEXT $4, V2.B8, V1.B8, V3.B8 // 2320022e VEXT $8, V2.B16, V1.B16, V3.B16 // 2340026e VRBIT V24.B16, V24.B16 // 185b606e VRBIT V24.B8, V24.B8 // 185b602e VUSHR $56, V1.D2, V2.D2 // 2204486f VUSHR $24, V1.S4, V2.S4 // 2204286f VUSHR $24, V1.S2, V2.S2 // 2204282f VUSHR $8, V1.H4, V2.H4 // 2204182f VUSHR $8, V1.H8, V2.H8 // 2204186f VUSHR $2, V1.B8, V2.B8 // 22040e2f VUSHR $2, V1.B16, V2.B16 // 22040e6f VSHL $56, V1.D2, V2.D2 // 2254784f VSHL $24, V1.S4, V2.S4 // 2254384f VSHL $24, V1.S2, V2.S2 // 2254380f VSHL $8, V1.H4, V2.H4 // 2254180f VSHL $8, V1.H8, V2.H8 // 2254184f VSHL $2, V1.B8, V2.B8 // 22540a0f VSHL $2, V1.B16, V2.B16 // 22540a4f VSRI $56, V1.D2, V2.D2 // 2244486f VSRI $24, V1.S4, V2.S4 // 2244286f VSRI $24, V1.S2, V2.S2 // 2244282f VSRI $8, V1.H4, V2.H4 // 2244182f VSRI $8, V1.H8, V2.H8 // 2244186f VSRI $2, V1.B8, V2.B8 // 22440e2f VSRI $2, V1.B16, V2.B16 // 22440e6f VSLI $7, V2.B16, V3.B16 // 43540f6f VSLI $15, V3.H4, V4.H4 // 64541f2f VSLI $31, V5.S4, V6.S4 // a6543f6f VSLI $63, V7.D2, V8.D2 // e8547f6f VUSRA $8, V2.B16, V3.B16 // 4314086f VUSRA $16, V3.H4, V4.H4 // 6414102f VUSRA $32, V5.S4, V6.S4 // a614206f VUSRA $64, V7.D2, V8.D2 // e814406f VTBL V22.B16, [V28.B16, V29.B16], V11.B16 // 8b23164e VTBL V18.B8, [V17.B16, V18.B16, V19.B16], V22.B8 // 3642120e VTBL V31.B8, [V14.B16, V15.B16, V16.B16, V17.B16], V15.B8 // cf611f0e VTBL V14.B16, [V16.B16], V11.B16 // 0b020e4e VTBL V28.B16, [V25.B16, V26.B16], V5.B16 // 25231c4e VTBL V16.B8, [V4.B16, V5.B16, V6.B16], V12.B8 // 8c40100e VTBL V4.B8, [V16.B16, V17.B16, V18.B16, V19.B16], V4.B8 // 0462040e VTBL V15.B8, [V1.B16], V20.B8 // 34000f0e VTBL V26.B16, [V2.B16, V3.B16], V26.B16 // 5a201a4e VTBL V15.B8, [V6.B16, V7.B16, V8.B16], V2.B8 // c2400f0e VTBL V2.B16, [V27.B16, V28.B16, V29.B16, V30.B16], V18.B16 // 7263024e VTBL V11.B16, [V13.B16], V27.B16 // bb010b4e VTBL V3.B8, [V7.B16, V8.B16], V25.B8 // f920030e VTBL V14.B16, [V3.B16, V4.B16, V5.B16], V17.B16 // 71400e4e VTBL V13.B16, [V29.B16, V30.B16, V31.B16, V0.B16], V28.B16 // bc630d4e VTBL V3.B8, [V27.B16], V8.B8 // 6803030e VTBX V22.B16, [V28.B16, V29.B16], V11.B16 // 8b33164e VTBX V18.B8, [V17.B16, V18.B16, V19.B16], V22.B8 // 3652120e VTBX V31.B8, [V14.B16, V15.B16, V16.B16, V17.B16], V15.B8 // cf711f0e VTBX V14.B16, [V16.B16], V11.B16 // 0b120e4e VTBX V28.B16, [V25.B16, V26.B16], V5.B16 // 25331c4e VTBX V16.B8, [V4.B16, V5.B16, V6.B16], V12.B8 // 8c50100e VTBX V4.B8, [V16.B16, V17.B16, V18.B16, V19.B16], V4.B8 // 0472040e VTBX V15.B8, [V1.B16], V20.B8 // 34100f0e VTBX V26.B16, [V2.B16, V3.B16], V26.B16 // 5a301a4e VTBX V15.B8, [V6.B16, V7.B16, V8.B16], V2.B8 // c2500f0e VTBX V2.B16, [V27.B16, V28.B16, V29.B16, V30.B16], V18.B16 // 7273024e VTBX V11.B16, [V13.B16], V27.B16 // bb110b4e VTBX V3.B8, [V7.B16, V8.B16], V25.B8 // f930030e VTBX V14.B16, [V3.B16, V4.B16, V5.B16], V17.B16 // 71500e4e VTBX V13.B16, [V29.B16, V30.B16, V31.B16, V0.B16], V28.B16 // bc730d4e VTBX V3.B8, [V27.B16], V8.B8 // 6813030e VZIP1 V16.H8, V3.H8, V19.H8 // 7338504e VZIP2 V22.D2, V25.D2, V21.D2 // 357bd64e VZIP1 V6.D2, V9.D2, V11.D2 // 2b39c64e VZIP2 V10.D2, V13.D2, V3.D2 // a379ca4e VZIP1 V17.S2, V4.S2, V26.S2 // 9a38910e VZIP2 V25.S2, V14.S2, V25.S2 // d979990e VUXTL V30.B8, V30.H8 // dea7082f VUXTL V30.H4, V29.S4 // dda7102f VUXTL V29.S2, V2.D2 // a2a7202f VUXTL2 V30.H8, V30.S4 // dea7106f VUXTL2 V29.S4, V2.D2 // a2a7206f VUXTL2 V30.B16, V2.H8 // c2a7086f VBIT V21.B16, V25.B16, V4.B16 // 241fb56e VBSL V23.B16, V3.B16, V7.B16 // 671c776e VCMTST V2.B8, V29.B8, V2.B8 // a28f220e VCMTST V2.D2, V23.D2, V3.D2 // e38ee24e VSUB V2.B8, V30.B8, V30.B8 // de87222e VUZP1 V0.B8, V30.B8, V1.B8 // c11b000e VUZP1 V1.B16, V29.B16, V2.B16 // a21b014e VUZP1 V2.H4, V28.H4, V3.H4 // 831b420e VUZP1 V3.H8, V27.H8, V4.H8 // 641b434e VUZP1 V28.S2, V2.S2, V5.S2 // 45189c0e VUZP1 V29.S4, V1.S4, V6.S4 // 26189d4e VUZP1 V30.D2, V0.D2, V7.D2 // 0718de4e VUZP2 V0.D2, V30.D2, V1.D2 // c15bc04e VUZP2 V30.D2, V0.D2, V29.D2 // 1d58de4e VUSHLL $0, V30.B8, V30.H8 // dea7082f VUSHLL $0, V30.H4, V29.S4 // dda7102f VUSHLL $0, V29.S2, V2.D2 // a2a7202f VUSHLL2 $0, V30.B16, V2.H8 // c2a7086f VUSHLL2 $0, V30.H8, V30.S4 // dea7106f VUSHLL2 $0, V29.S4, V2.D2 // a2a7206f VUSHLL $7, V30.B8, V30.H8 // dea70f2f VUSHLL $15, V30.H4, V29.S4 // dda71f2f VUSHLL2 $31, V30.S4, V2.D2 // c2a73f6f VBIF V0.B8, V30.B8, V1.B8 // c11fe02e VBIF V30.B16, V0.B16, V2.B16 // 021cfe6e FMOVS $(4.0), F0 // 0010221e FMOVD $(4.0), F0 // 0010621e FMOVS $(0.265625), F1 // 01302a1e FMOVD $(0.1796875), F2 // 02f0681e FMOVS $(0.96875), F3 // 03f02d1e FMOVD $(28.0), F4 // 0490671e FMOVD $0, F0 // e003679e FMOVS $0, F0 // e003271e FMOVD ZR, F0 // e003679e FMOVS ZR, F0 // e003271e FMOVD F1, ZR // 3f00669e FMOVS F1, ZR // 3f00261e VUADDW V9.B8, V12.H8, V14.H8 // 8e11292e VUADDW V13.H4, V10.S4, V11.S4 // 4b116d2e VUADDW V21.S2, V24.D2, V29.D2 // 1d13b52e VUADDW2 V9.B16, V12.H8, V14.H8 // 8e11296e VUADDW2 V13.H8, V20.S4, V30.S4 // 9e126d6e VUADDW2 V21.S4, V24.D2, V29.D2 // 1d13b56e VUMAX V3.B8, V2.B8, V1.B8 // 4164232e VUMAX V3.B16, V2.B16, V1.B16 // 4164236e VUMAX V3.H4, V2.H4, V1.H4 // 4164632e VUMAX V3.H8, V2.H8, V1.H8 // 4164636e VUMAX V3.S2, V2.S2, V1.S2 // 4164a32e VUMAX V3.S4, V2.S4, V1.S4 // 4164a36e VUMIN V3.B8, V2.B8, V1.B8 // 416c232e VUMIN V3.B16, V2.B16, V1.B16 // 416c236e VUMIN V3.H4, V2.H4, V1.H4 // 416c632e VUMIN V3.H8, V2.H8, V1.H8 // 416c636e VUMIN V3.S2, V2.S2, V1.S2 // 416ca32e VUMIN V3.S4, V2.S4, V1.S4 // 416ca36e FCCMPS LT, F1, F2, $1 // 41b4211e FMADDS F1, F3, F2, F4 // 440c011f FMADDD F4, F5, F4, F4 // 8414441f FMSUBS F13, F21, F13, F19 // b3d50d1f FMSUBD F11, F7, F15, F31 // ff9d4b1f FNMADDS F1, F3, F2, F4 // 440c211f FNMADDD F1, F3, F2, F4 // 440c611f FNMSUBS F1, F3, F2, F4 // 448c211f FNMSUBD F1, F3, F2, F4 // 448c611f FADDS F2, F3, F4 // 6428221e FADDD F1, F2 // 4228611e VDUP V19.S[0], V17.S4 // 7106044e VTRN1 V3.D2, V2.D2, V20.D2 // 5428c34e VTRN2 V3.D2, V2.D2, V21.D2 // 5568c34e VTRN1 V5.D2, V4.D2, V22.D2 // 9628c54e VTRN2 V5.D2, V4.D2, V23.D2 // 9768c54e // special PRFM (R2), PLDL1KEEP // 400080f9 PRFM 16(R2), PLDL1KEEP // 400880f9 PRFM 48(R6), PSTL2STRM // d31880f9 PRFM 8(R12), PLIL3STRM // 8d0580f9 PRFM (R8), $25 // 190180f9 PRFM 8(R9), $30 // 3e0580f9 NOOP // 1f2003d5 HINT $0 // 1f2003d5 DMB $1 SVC // encryption SHA256H V9.S4, V3, V2 // 6240095e SHA256H2 V9.S4, V4, V3 // 8350095e SHA256SU0 V8.S4, V7.S4 // 0729285e SHA256SU1 V6.S4, V5.S4, V7.S4 // a760065e SHA1SU0 V11.S4, V8.S4, V6.S4 // 06310b5e SHA1SU1 V5.S4, V1.S4 // a118285e SHA1C V1.S4, V2, V3 // 4300015e SHA1H V5, V4 // a408285e SHA1M V8.S4, V7, V6 // e620085e SHA1P V11.S4, V10, V9 // 49110b5e SHA512H V2.D2, V1, V0 // 208062ce SHA512H2 V4.D2, V3, V2 // 628464ce SHA512SU0 V9.D2, V8.D2 // 2881c0ce SHA512SU1 V7.D2, V6.D2, V5.D2 // c58867ce VRAX1 V26.D2, V29.D2, V30.D2 // be8f7ace VXAR $63, V27.D2, V21.D2, V26.D2 // bafe9bce VPMULL V2.D1, V1.D1, V3.Q1 // 23e0e20e VPMULL2 V2.D2, V1.D2, V4.Q1 // 24e0e24e VPMULL V2.B8, V1.B8, V3.H8 // 23e0220e VPMULL2 V2.B16, V1.B16, V4.H8 // 24e0224e VEOR3 V2.B16, V7.B16, V12.B16, V25.B16 // 990907ce VBCAX V1.B16, V2.B16, V26.B16, V31.B16 // 5f0722ce VREV32 V5.B16, V5.B16 // a508206e VREV64 V2.S2, V3.S2 // 4308a00e VREV64 V2.S4, V3.S4 // 4308a04e // logical ops // // make sure constants get encoded into an instruction when it could AND R1@>33, R2 AND $(1<<63), R1 // AND $-9223372036854775808, R1 // 21004192 AND $(1<<63-1), R1 // AND $9223372036854775807, R1 // 21f84092 ORR $(1<<63), R1 // ORR $-9223372036854775808, R1 // 210041b2 ORR $(1<<63-1), R1 // ORR $9223372036854775807, R1 // 21f840b2 EOR $(1<<63), R1 // EOR $-9223372036854775808, R1 // 210041d2 EOR $(1<<63-1), R1 // EOR $9223372036854775807, R1 // 21f840d2 ANDW $0x3ff00000, R2 // ANDW $1072693248, R2 // 42240c12 BICW $0x3ff00000, R2 // BICW $1072693248, R2 // 42540212 ORRW $0x3ff00000, R2 // ORRW $1072693248, R2 // 42240c32 ORNW $0x3ff00000, R2 // ORNW $1072693248, R2 // 42540232 EORW $0x3ff00000, R2 // EORW $1072693248, R2 // 42240c52 EONW $0x3ff00000, R2 // EONW $1072693248, R2 // 42540252 AND $0x22220000, R3, R4 // AND $572653568, R3, R4 // 5b44a4d264001b8a ORR $0x22220000, R3, R4 // ORR $572653568, R3, R4 // 5b44a4d264001baa EOR $0x22220000, R3, R4 // EOR $572653568, R3, R4 // 5b44a4d264001bca BIC $0x22220000, R3, R4 // BIC $572653568, R3, R4 // 5b44a4d264003b8a ORN $0x22220000, R3, R4 // ORN $572653568, R3, R4 // 5b44a4d264003baa EON $0x22220000, R3, R4 // EON $572653568, R3, R4 // 5b44a4d264003bca ANDS $0x22220000, R3, R4 // ANDS $572653568, R3, R4 // 5b44a4d264001bea BICS $0x22220000, R3, R4 // BICS $572653568, R3, R4 // 5b44a4d264003bea EOR $0xe03fffffffffffff, R20, R22 // EOR $-2287828610704211969, R20, R22 // 96e243d2 TSTW $0x600000006, R1 // TSTW $25769803782, R1 // 3f041f72 TST $0x4900000049, R0 // TST $313532612681, R0 // 3b0980d23b09c0f21f001bea ORR $0x170000, R2, R1 // ORR $1507328, R2, R1 // fb02a0d241001baa AND $0xff00ff, R2 // AND $16711935, R2 // fb1f80d2fb1fa0f242001b8a AND $0xff00ffff, R1 // AND $4278255615, R1 // fbff9fd21be0bff221001b8a ANDS $0xffff, R2 // ANDS $65535, R2 // 423c40f2 AND $0x7fffffff, R3 // AND $2147483647, R3 // 63784092 ANDS $0x0ffffffff80000000, R2 // ANDS $-2147483648, R2 // 428061f2 AND $0xfffff, R2 // AND $1048575, R2 // 424c4092 ANDW $0xf00fffff, R1 // ANDW $4027580415, R1 // 215c0412 ANDSW $0xff00ffff, R1 // ANDSW $4278255615, R1 // 215c0872 TST $0x11223344, R2 // TST $287454020, R2 // 9b6886d25b24a2f25f001bea TSTW $0xa000, R3 // TSTW $40960, R3 // 1b0094527f001b6a BICW $0xa000, R3 // BICW $40960, R3 // 1b00945263003b0a ORRW $0x1b000, R2, R3 // ORRW $110592, R2, R3 // 1b0096523b00a07243001b2a TSTW $0x500000, R1 // TSTW $5242880, R1 // 1b0aa0523f001b6a TSTW $0xff00ff, R1 // TSTW $16711935, R1 // 3f9c0072 TSTW $0x60060, R5 // TSTW $393312, R5 // 1b0c8052db00a072bf001b6a TSTW $0x6006000060060, R5 // TSTW $1689262177517664, R5 // 1b0c8052db00a072bf001b6a ANDW $0x6006000060060, R5 // ANDW $1689262177517664, R5 // 1b0c8052db00a072a5001b0a ANDSW $0x6006000060060, R5 // ANDSW $1689262177517664, R5 // 1b0c8052db00a072a5001b6a EORW $0x6006000060060, R5 // EORW $1689262177517664, R5 // 1b0c8052db00a072a5001b4a ORRW $0x6006000060060, R5 // ORRW $1689262177517664, R5 // 1b0c8052db00a072a5001b2a BICW $0x6006000060060, R5 // BICW $1689262177517664, R5 // 1b0c8052db00a072a5003b0a EONW $0x6006000060060, R5 // EONW $1689262177517664, R5 // 1b0c8052db00a072a5003b4a ORNW $0x6006000060060, R5 // ORNW $1689262177517664, R5 // 1b0c8052db00a072a5003b2a BICSW $0x6006000060060, R5 // BICSW $1689262177517664, R5 // 1b0c8052db00a072a5003b6a AND $1, ZR // fb0340b2ff031b8a ANDW $1, ZR // fb030032ff031b0a // TODO: this could have better encoding ANDW $-1, R10 // 1b0080124a011b0a AND $8, R0, RSP // 1f007d92 ORR $8, R0, RSP // 1f007db2 EOR $8, R0, RSP // 1f007dd2 BIC $8, R0, RSP // 1ff87c92 ORN $8, R0, RSP // 1ff87cb2 EON $8, R0, RSP // 1ff87cd2 TST $15, R2 // 5f0c40f2 TST R1, R2 // 5f0001ea TST R1->11, R2 // 5f2c81ea TST R1>>22, R2 // 5f5841ea TST R1<<33, R2 // 5f8401ea TST $0x22220000, R3 // TST $572653568, R3 // 5b44a4d27f001bea // move an immediate to a Rn. MOVD $0x3fffffffc000, R0 // MOVD $70368744161280, R0 // e07f72b2 MOVW $1000000, R4 // 04488852e401a072 MOVW $0xaaaa0000, R1 // MOVW $2863267840, R1 // 4155b552 MOVW $0xaaaaffff, R1 // MOVW $2863333375, R1 // a1aaaa12 MOVW $0xaaaa, R1 // MOVW $43690, R1 // 41559552 MOVW $0xffffaaaa, R1 // MOVW $4294945450, R1 // a1aa8a12 MOVW $0xffff0000, R1 // MOVW $4294901760, R1 // e1ffbf52 MOVD $0xffff00000000000, R1 // MOVD $1152903912420802560, R1 // e13f54b2 MOVD $0x1111000000001111, R1 // MOVD $1229764173248860433, R1 // 212282d22122e2f2 MOVD $0x1111ffff1111ffff, R1 // MOVD $1230045644216991743, R1 // c1ddbd922122e2f2 MOVD $0x1111222233334444, R1 // MOVD $1229801703532086340, R1 // 818888d26166a6f24144c4f22122e2f2 MOVD $0xaaaaffff, R1 // MOVD $2863333375, R1 // e1ff9fd24155b5f2 MOVD $0x11110000, R1 // MOVD $286326784, R1 // 2122a2d2 MOVD $0xaaaa0000aaaa1111, R1 // MOVD $-6149102338357718767, R1 // 212282d24155b5f24155f5f2 MOVD $0x1111ffff1111aaaa, R1 // MOVD $1230045644216969898, R1 // a1aa8a922122a2f22122e2f2 MOVD $0, R1 // e1031faa MOVD $-1, R1 // 01008092 MOVD $0x210000, R0 // MOVD $2162688, R0 // 2004a0d2 MOVD $0xffffffffffffaaaa, R1 // MOVD $-21846, R1 // a1aa8a92 MOVW $1, ZR // 3f008052 MOVW $1, R1 MOVD $1, ZR // 3f0080d2 MOVD $1, R1 MOVK $1, R1 MOVD $0x1000100010001000, RSP // MOVD $1152939097061330944, RSP // ff8304b2 MOVW $0x10001000, RSP // MOVW $268439552, RSP // ff830432 ADDW $0x10001000, R1 // ADDW $268439552, R1 // fb83043221001b0b ADDW $0x22220000, RSP, R3 // ADDW $572653568, RSP, R3 // 5b44a452e3433b0b // move a large constant to a Vd. VMOVS $0x80402010, V11 // VMOVS $2151686160, V11 VMOVD $0x8040201008040201, V20 // VMOVD $-9205322385119247871, V20 VMOVQ $0x7040201008040201, $0x8040201008040201, V10 // VMOVQ $8088500183983456769, $-9205322385119247871, V10 VMOVQ $0x8040201008040202, $0x7040201008040201, V20 // VMOVQ $-9205322385119247870, $8088500183983456769, V20 // mov(to/from sp) MOVD $0x1002(RSP), R1 // MOVD $4098(RSP), R1 // e107409121080091 MOVD $0x1708(RSP), RSP // MOVD $5896(RSP), RSP // ff074091ff231c91 MOVD $0x2001(R7), R1 // MOVD $8193(R7), R1 // e108409121040091 MOVD $0xffffff(R7), R1 // MOVD $16777215(R7), R1 // e1fc7f9121fc3f91 MOVD $-0x1(R7), R1 // MOVD $-1(R7), R1 // e10400d1 MOVD $-0x30(R7), R1 // MOVD $-48(R7), R1 // e1c000d1 MOVD $-0x708(R7), R1 // MOVD $-1800(R7), R1 // e1201cd1 MOVD $-0x2000(RSP), R1 // MOVD $-8192(RSP), R1 // e10b40d1 MOVD $-0x10000(RSP), RSP // MOVD $-65536(RSP), RSP // ff4340d1 MOVW R1, R2 MOVW ZR, R1 MOVW R1, ZR MOVD R1, R2 MOVD ZR, R1 // store and load // // LD1/ST1 VLD1 (R8), [V1.B16, V2.B16] // 01a1404c VLD1.P (R3), [V31.H8, V0.H8] // 7fa4df4c VLD1.P (R8)(R20), [V21.B16, V22.B16] // 15a1d44c VLD1.P 64(R1), [V5.B16, V6.B16, V7.B16, V8.B16] // 2520df4c VLD1.P 1(R0), V4.B[15] // 041cdf4d VLD1.P 2(R0), V4.H[7] // 0458df4d VLD1.P 4(R0), V4.S[3] // 0490df4d VLD1.P 8(R0), V4.D[1] // 0484df4d VLD1.P (R0)(R1), V4.D[1] // 0484c14d VLD1 (R0), V4.D[1] // 0484404d VST1.P [V4.S4, V5.S4], 32(R1) // 24a89f4c VST1 [V0.S4, V1.S4], (R0) // 00a8004c VLD1 (R30), [V15.S2, V16.S2] // cfab400c VLD1.P 24(R30), [V3.S2,V4.S2,V5.S2] // c36bdf0c VLD2 (R29), [V23.H8, V24.H8] // b787404c VLD2.P 16(R0), [V18.B8, V19.B8] // 1280df0c VLD2.P (R1)(R2), [V15.S2, V16.S2] // 2f88c20c VLD3 (R27), [V11.S4, V12.S4, V13.S4] // 6b4b404c VLD3.P 48(RSP), [V11.S4, V12.S4, V13.S4] // eb4bdf4c VLD3.P (R30)(R2), [V14.D2, V15.D2, V16.D2] // ce4fc24c VLD4 (R15), [V10.H4, V11.H4, V12.H4, V13.H4] // ea05400c VLD4.P 32(R24), [V31.B8, V0.B8, V1.B8, V2.B8] // 1f03df0c VLD4.P (R13)(R9), [V14.S2, V15.S2, V16.S2, V17.S2] // ae09c90c VLD1R (R1), [V9.B8] // 29c0400d VLD1R.P (R1), [V9.B8] // 29c0df0d VLD1R.P 1(R1), [V2.B8] // 22c0df0d VLD1R.P 2(R1), [V2.H4] // 22c4df0d VLD1R (R0), [V0.B16] // 00c0404d VLD1R.P (R0), [V0.B16] // 00c0df4d VLD1R.P (R15)(R1), [V15.H4] // efc5c10d VLD2R (R15), [V15.H4, V16.H4] // efc5600d VLD2R.P 16(R0), [V0.D2, V1.D2] // 00ccff4d VLD2R.P (R0)(R5), [V31.D1, V0.D1] // 1fcce50d VLD3R (RSP), [V31.S2, V0.S2, V1.S2] // ffeb400d VLD3R.P 6(R15), [V15.H4, V16.H4, V17.H4] // efe5df0d VLD3R.P (R15)(R6), [V15.H8, V16.H8, V17.H8] // efe5c64d VLD4R (R0), [V0.B8, V1.B8, V2.B8, V3.B8] // 00e0600d VLD4R.P 16(RSP), [V31.S4, V0.S4, V1.S4, V2.S4] // ffebff4d VLD4R.P (R15)(R9), [V15.H4, V16.H4, V17.H4, V18.H4] // efe5e90d VST1.P [V24.S2], 8(R2) // 58789f0c VST1 [V29.S2, V30.S2], (R29) // bdab000c VST1 [V14.H4, V15.H4, V16.H4], (R27) // 6e67000c VST1.P V4.B[15], 1(R0) // 041c9f4d VST1.P V4.H[7], 2(R0) // 04589f4d VST1.P V4.S[3], 4(R0) // 04909f4d VST1.P V4.D[1], 8(R0) // 04849f4d VST1.P V4.D[1], (R0)(R1) // 0484814d VST1 V4.D[1], (R0) // 0484004d VST2 [V22.H8, V23.H8], (R23) // f686004c VST2.P [V14.H4, V15.H4], 16(R17) // 2e869f0c VST2.P [V14.H4, V15.H4], (R3)(R17) // 6e84910c VST3 [V1.D2, V2.D2, V3.D2], (R11) // 614d004c VST3.P [V18.S4, V19.S4, V20.S4], 48(R25) // 324b9f4c VST3.P [V19.B8, V20.B8, V21.B8], (R3)(R7) // 7340870c VST4 [V22.D2, V23.D2, V24.D2, V25.D2], (R3) // 760c004c VST4.P [V14.D2, V15.D2, V16.D2, V17.D2], 64(R15) // ee0d9f4c VST4.P [V24.B8, V25.B8, V26.B8, V27.B8], (R3)(R23) // 7800970c // pre/post-indexed FMOVS.P F20, 4(R0) // 144400bc FMOVS.W F20, 4(R0) // 144c00bc FMOVD.P F20, 8(R1) // 348400fc FMOVQ.P F13, 11(R10) // 4db5803c FMOVQ.W F15, 11(R20) // 8fbe803c FMOVS.P 8(R0), F20 // 148440bc FMOVS.W 8(R0), F20 // 148c40bc FMOVD.W 8(R1), F20 // 348c40fc FMOVQ.P 11(R10), F13 // 4db5c03c FMOVQ.W 11(R20), F15 // 8fbec03c // storing $0 to memory, $0 will be replaced with ZR. MOVD $0, (R1) // 3f0000f9 MOVW $0, (R1) // 3f0000b9 MOVWU $0, (R1) // 3f0000b9 MOVH $0, (R1) // 3f000079 MOVHU $0, (R1) // 3f000079 MOVB $0, (R1) // 3f000039 MOVBU $0, (R1) // 3f000039 // small offset fits into instructions MOVB R1, 1(R2) // 41040039 MOVH R1, 1(R2) // 41100078 MOVH R1, 2(R2) // 41040079 MOVW R1, 1(R2) // 411000b8 MOVW R1, 4(R2) // 410400b9 MOVD R1, 1(R2) // 411000f8 MOVD R1, 8(R2) // 410400f9 MOVD ZR, (R1) MOVW ZR, (R1) FMOVS F1, 1(R2) // 411000bc FMOVS F1, 4(R2) // 410400bd FMOVS F20, (R0) // 140000bd FMOVD F1, 1(R2) // 411000fc FMOVD F1, 8(R2) // 410400fd FMOVD F20, (R2) // 540000fd FMOVQ F0, 32(R5)// a008803d FMOVQ F10, 65520(R10) // 4afdbf3d FMOVQ F11, 64(RSP) // eb13803d FMOVQ F11, 8(R20) // 8b82803c FMOVQ F11, 4(R20) // 8b42803c MOVB 1(R1), R2 // 22048039 MOVH 1(R1), R2 // 22108078 MOVH 2(R1), R2 // 22048079 MOVW 1(R1), R2 // 221080b8 MOVW 4(R1), R2 // 220480b9 MOVD 1(R1), R2 // 221040f8 MOVD 8(R1), R2 // 220440f9 FMOVS (R0), F20 // 140040bd FMOVS 1(R1), F2 // 221040bc FMOVS 4(R1), F2 // 220440bd FMOVD 1(R1), F2 // 221040fc FMOVD 8(R1), F2 // 220440fd FMOVQ 32(R5), F2 // a208c03d FMOVQ 65520(R10), F10 // 4afdff3d FMOVQ 64(RSP), F11 // eb13c03d // medium offsets that either fit a single instruction or can use add+ldr/str MOVD -4095(R17), R3 // 3bfe3fd1630340f9 MOVD -391(R17), R3 // 3b1e06d1630340f9 MOVD -257(R17), R3 // 3b0604d1630340f9 MOVD -256(R17), R3 // 230250f8 MOVD 255(R17), R3 // 23f24ff8 MOVD 256(R17), R3 // 238240f9 MOVD 257(R17), R3 // 3b060491630340f9 MOVD 391(R17), R3 // 3b1e0691630340f9 MOVD 4095(R17), R3 // 3bfe3f91630340f9 MOVD R0, -4095(R17) // 3bfe3fd1600300f9 MOVD R0, -391(R17) // 3b1e06d1600300f9 MOVD R0, -257(R17) // 3b0604d1600300f9 MOVD R0, -256(R17) // 200210f8 MOVD R0, 255(R17) // 20f20ff8 MOVD R0, 256(R17) // 208200f9 MOVD R0, 257(R17) // 3b060491600300f9 MOVD R0, 391(R17) // 3b1e0691600300f9 MOVD R0, 4095(R17) // 3bfe3f91600300f9 MOVD R0, 4096(R17) // 200208f9 MOVD R3, -4095(R17) // 3bfe3fd1630300f9 MOVD R3, -391(R17) // 3b1e06d1630300f9 MOVD R3, -257(R17) // 3b0604d1630300f9 MOVD R3, -256(R17) // 230210f8 MOVD R3, 255(R17) // 23f20ff8 MOVD R3, 256(R17) // 238200f9 MOVD R3, 257(R17) // 3b060491630300f9 MOVD R3, 391(R17) // 3b1e0691630300f9 MOVD R3, 4095(R17) // 3bfe3f91630300f9 // large aligned offset, use two instructions(add+ldr/str). MOVB R1, 0x1001(R2) // MOVB R1, 4097(R2) // 5b04409161070039 MOVB R1, 0xffffff(R2) // MOVB R1, 16777215(R2) // 5bfc7f9161ff3f39 MOVH R1, 0x2002(R2) // MOVH R1, 8194(R2) // 5b08409161070079 MOVH R1, 0x1000ffe(R2) // MOVH R1, 16781310(R2) // 5bfc7f9161ff3f79 MOVW R1, 0x4004(R2) // MOVW R1, 16388(R2) // 5b104091610700b9 MOVW R1, 0x1002ffc(R2) // MOVW R1, 16789500(R2) // 5bfc7f9161ff3fb9 MOVD R1, 0x8008(R2) // MOVD R1, 32776(R2) // 5b204091610700f9 MOVD R1, 0x1006ff8(R2) // MOVD R1, 16805880(R2) // 5bfc7f9161ff3ff9 FMOVS F1, 0x4004(R2) // FMOVS F1, 16388(R2) // 5b104091610700bd FMOVS F1, 0x1002ffc(R2) // FMOVS F1, 16789500(R2) // 5bfc7f9161ff3fbd FMOVD F1, 0x8008(R2) // FMOVD F1, 32776(R2) // 5b204091610700fd FMOVD F1, 0x1006ff8(R2) // FMOVD F1, 16805880(R2) // 5bfc7f9161ff3ffd MOVB 0x1001(R1), R2 // MOVB 4097(R1), R2 // 3b04409162078039 MOVB 0xffffff(R1), R2 // MOVB 16777215(R1), R2 // 3bfc7f9162ffbf39 MOVH 0x2002(R1), R2 // MOVH 8194(R1), R2 // 3b08409162078079 MOVH 0x1000ffe(R1), R2 // MOVH 16781310(R1), R2 // 3bfc7f9162ffbf79 MOVW 0x4004(R1), R2 // MOVW 16388(R1), R2 // 3b104091620780b9 MOVW 0x1002ffc(R1), R2 // MOVW 16789500(R1), R2 // 3bfc7f9162ffbfb9 MOVD 0x8008(R1), R2 // MOVD 32776(R1), R2 // 3b204091620740f9 MOVD 0x1006ff8(R1), R2 // MOVD 16805880(R1), R2 // 3bfc7f9162ff7ff9 FMOVS 0x4004(R1), F2 // FMOVS 16388(R1), F2 // 3b104091620740bd FMOVS 0x1002ffc(R1), F2 // FMOVS 16789500(R1), F2 // 3bfc7f9162ff7fbd FMOVD 0x8008(R1), F2 // FMOVD 32776(R1), F2 // 3b204091620740fd FMOVD 0x1006ff8(R1), F2 // FMOVD 16805880(R1), F2 // 3bfc7f9162ff7ffd // very large or unaligned offset uses constant pool. // the encoding cannot be checked as the address of the constant pool is unknown. // here we only test that they can be assembled. MOVB R1, 0x1000000(R2) // MOVB R1, 16777216(R2) MOVB R1, 0x44332211(R2) // MOVB R1, 1144201745(R2) MOVH R1, 0x1001000(R2) // MOVH R1, 16781312(R2) MOVH R1, 0x44332211(R2) // MOVH R1, 1144201745(R2) MOVW R1, 0x1003000(R2) // MOVW R1, 16789504(R2) MOVW R1, 0x44332211(R2) // MOVW R1, 1144201745(R2) MOVD R1, 0x1007000(R2) // MOVD R1, 16805888(R2) MOVD R1, 0x44332211(R2) // MOVD R1, 1144201745(R2) FMOVS F1, 0x1003000(R2) // FMOVS F1, 16789504(R2) FMOVS F1, 0x44332211(R2) // FMOVS F1, 1144201745(R2) FMOVD F1, 0x1007000(R2) // FMOVD F1, 16805888(R2) FMOVD F1, 0x44332211(R2) // FMOVD F1, 1144201745(R2) MOVB 0x1000000(R1), R2 // MOVB 16777216(R1), R2 MOVB 0x44332211(R1), R2 // MOVB 1144201745(R1), R2 MOVH 0x1000000(R1), R2 // MOVH 16777216(R1), R2 MOVH 0x44332211(R1), R2 // MOVH 1144201745(R1), R2 MOVW 0x1000000(R1), R2 // MOVW 16777216(R1), R2 MOVW 0x44332211(R1), R2 // MOVW 1144201745(R1), R2 MOVD 0x1000000(R1), R2 // MOVD 16777216(R1), R2 MOVD 0x44332211(R1), R2 // MOVD 1144201745(R1), R2 FMOVS 0x1000000(R1), F2 // FMOVS 16777216(R1), F2 FMOVS 0x44332211(R1), F2 // FMOVS 1144201745(R1), F2 FMOVD 0x1000000(R1), F2 // FMOVD 16777216(R1), F2 FMOVD 0x44332211(R1), F2 // FMOVD 1144201745(R1), F2 // shifted or extended register offset. MOVD (R2)(R6.SXTW), R4 // 44c866f8 MOVD (R3)(R6), R5 // 656866f8 MOVD (R3)(R6*1), R5 // 656866f8 MOVD (R2)(R6), R4 // 446866f8 MOVWU (R19)(R20<<2), R20 // 747a74b8 MOVD (R2)(R3<<0), R1 // 416863f8 MOVD (R2)(R6<<3), R4 // 447866f8 MOVD (R3)(R7.SXTX<<3), R8 // 68f867f8 MOVWU (R5)(R4.UXTW), R10 // aa4864b8 MOVBU (R3)(R9.UXTW), R8 // 68486938 MOVBU (R5)(R8), R10 // aa686838 MOVHU (R2)(R7.SXTW<<1), R11 // 4bd86778 MOVHU (R1)(R2<<1), R5 // 25786278 MOVB (R9)(R3.UXTW), R6 // 2649a338 MOVB (R10)(R6), R15 // 4f69a638 MOVB (R29)(R30<<0), R14 // ae6bbe38 MOVB (R29)(R30), R14 // ae6bbe38 MOVH (R5)(R7.SXTX<<1), R19 // b3f8a778 MOVH (R8)(R4<<1), R10 // 0a79a478 MOVW (R9)(R8.SXTW<<2), R19 // 33d9a8b8 MOVW (R1)(R4.SXTX), R11 // 2be8a4b8 MOVW (R1)(R4.SXTX), ZR // 3fe8a4b8 MOVW (R2)(R5), R12 // 4c68a5b8 FMOVS (R2)(R6), F4 // 446866bc FMOVS (R2)(R6<<2), F4 // 447866bc FMOVD (R2)(R6), F4 // 446866fc FMOVD (R2)(R6<<3), F4 // 447866fc MOVD R5, (R2)(R6<<3) // 457826f8 MOVD R9, (R6)(R7.SXTX<<3) // c9f827f8 MOVD ZR, (R6)(R7.SXTX<<3) // dff827f8 MOVW R8, (R2)(R3.UXTW<<2) // 485823b8 MOVW R7, (R3)(R4.SXTW) // 67c824b8 MOVB R4, (R2)(R6.SXTX) // 44e82638 MOVB R8, (R3)(R9.UXTW) // 68482938 MOVB R10, (R5)(R8) // aa682838 MOVB R10, (R5)(R8*1) // aa682838 MOVH R11, (R2)(R7.SXTW<<1) // 4bd82778 MOVH R5, (R1)(R2<<1) // 25782278 MOVH R7, (R2)(R5.SXTX<<1) // 47f82578 MOVH R8, (R3)(R6.UXTW) // 68482678 MOVB R4, (R2)(R6.SXTX) // 44e82638 FMOVS F4, (R2)(R6) // 446826bc FMOVS F4, (R2)(R6<<2) // 447826bc FMOVD F4, (R2)(R6) // 446826fc FMOVD F4, (R2)(R6<<3) // 447826fc // vmov VMOV V8.S[1], R1 // 013d0c0e VMOV V0.D[0], R11 // 0b3c084e VMOV V0.D[1], R11 // 0b3c184e VMOV R20, V1.S[0] // 811e044e VMOV R20, V1.S[1] // 811e0c4e VMOV R1, V9.H4 // 290c020e VDUP R1, V9.H4 // 290c020e VMOV R22, V11.D2 // cb0e084e VDUP R22, V11.D2 // cb0e084e VMOV V2.B16, V4.B16 // 441ca24e VMOV V20.S[0], V20 // 9406045e VDUP V20.S[0], V20 // 9406045e VMOV V12.D[0], V12.D[1] // 8c05186e VMOV V10.S[0], V12.S[1] // 4c050c6e VMOV V9.H[0], V12.H[1] // 2c05066e VMOV V8.B[0], V12.B[1] // 0c05036e VMOV V8.B[7], V4.B[8] // 043d116e // CBZ again: CBZ R1, again // CBZ R1 // conditional operations CSET GT, R1 // e1d79f9a CSETW HI, R2 // e2979f1a CSEL LT, R1, R2, ZR // 3fb0829a CSELW LT, R2, R3, R4 // 44b0831a CSINC GT, R1, ZR, R3 // 23c49f9a CSNEG MI, R1, R2, R3 // 234482da CSINV CS, R1, R2, R3 // CSINV HS, R1, R2, R3 // 232082da CSINV HS, R1, R2, R3 // 232082da CSINVW MI, R2, ZR, R2 // 42409f5a CINC EQ, R4, R9 // 8914849a CINCW PL, R2, ZR // 5f44821a CINV PL, R11, R22 // 76418bda CINVW LS, R7, R13 // ed80875a CNEG LS, R13, R7 // a7858dda CNEGW EQ, R8, R13 // 0d15885a // atomic ops LDARB (R25), R2 // 22ffdf08 LDARH (R5), R7 // a7fcdf48 LDAXPW (R10), (R20, R16) // 54c17f88 LDAXP (R25), (R30, R11) // 3eaf7fc8 LDAXRW (R0), R2 // 02fc5f88 LDXPW (R24), (R23, R11) // 172f7f88 LDXP (R0), (R16, R13) // 10347fc8 STLRB R11, (R22) // cbfe9f08 STLRH R16, (R23) // f0fe9f48 STLXP (R6, R3), (R10), R2 // 468d22c8 STLXPW (R6, R11), (R22), R21 // c6ae3588 STLXRW R1, (R0), R3 // 01fc0388 STXP (R1, R2), (R3), R10 // 61082ac8 STXP (R1, R2), (RSP), R10 // e10b2ac8 STXPW (R1, R2), (R3), R10 // 61082a88 STXPW (R1, R2), (RSP), R10 // e10b2a88 SWPAD R5, (R6), R7 // c780a5f8 SWPAD R5, (RSP), R7 // e783a5f8 SWPAW R5, (R6), R7 // c780a5b8 SWPAW R5, (RSP), R7 // e783a5b8 SWPAH R5, (R6), R7 // c780a578 SWPAH R5, (RSP), R7 // e783a578 SWPAB R5, (R6), R7 // c780a538 SWPAB R5, (RSP), R7 // e783a538 SWPALD R5, (R6), R7 // c780e5f8 SWPALD R5, (RSP), R7 // e783e5f8 SWPALW R5, (R6), R7 // c780e5b8 SWPALW R5, (RSP), R7 // e783e5b8 SWPALH R5, (R6), R7 // c780e578 SWPALH R5, (RSP), R7 // e783e578 SWPALB R5, (R6), R7 // c780e538 SWPALB R5, (RSP), R7 // e783e538 SWPD R5, (R6), R7 // c78025f8 SWPD R5, (RSP), R7 // e78325f8 SWPW R5, (R6), R7 // c78025b8 SWPW R5, (RSP), R7 // e78325b8 SWPH R5, (R6), R7 // c7802578 SWPH R5, (RSP), R7 // e7832578 SWPB R5, (R6), R7 // c7802538 SWPB R5, (RSP), R7 // e7832538 SWPLD R5, (R6), R7 // c78065f8 SWPLD R5, (RSP), R7 // e78365f8 SWPLW R5, (R6), R7 // c78065b8 SWPLW R5, (RSP), R7 // e78365b8 SWPLH R5, (R6), R7 // c7806578 SWPLH R5, (RSP), R7 // e7836578 SWPLB R5, (R6), R7 // c7806538 SWPLB R5, (RSP), R7 // e7836538 LDADDAD R5, (R6), R7 // c700a5f8 LDADDAD R5, (RSP), R7 // e703a5f8 LDADDAW R5, (R6), R7 // c700a5b8 LDADDAW R5, (RSP), R7 // e703a5b8 LDADDAH R5, (R6), R7 // c700a578 LDADDAH R5, (RSP), R7 // e703a578 LDADDAB R5, (R6), R7 // c700a538 LDADDAB R5, (RSP), R7 // e703a538 LDADDALD R5, (R6), R7 // c700e5f8 LDADDALD R5, (RSP), R7 // e703e5f8 LDADDALW R5, (R6), R7 // c700e5b8 LDADDALW R5, (RSP), R7 // e703e5b8 LDADDALH R5, (R6), R7 // c700e578 LDADDALH R5, (RSP), R7 // e703e578 LDADDALB R5, (R6), R7 // c700e538 LDADDALB R5, (RSP), R7 // e703e538 LDADDD R5, (R6), R7 // c70025f8 LDADDD R5, (RSP), R7 // e70325f8 LDADDW R5, (R6), R7 // c70025b8 LDADDW R5, (RSP), R7 // e70325b8 LDADDH R5, (R6), R7 // c7002578 LDADDH R5, (RSP), R7 // e7032578 LDADDB R5, (R6), R7 // c7002538 LDADDB R5, (RSP), R7 // e7032538 LDADDLD R5, (R6), R7 // c70065f8 LDADDLD R5, (RSP), R7 // e70365f8 LDADDLW R5, (R6), R7 // c70065b8 LDADDLW R5, (RSP), R7 // e70365b8 LDADDLH R5, (R6), R7 // c7006578 LDADDLH R5, (RSP), R7 // e7036578 LDADDLB R5, (R6), R7 // c7006538 LDADDLB R5, (RSP), R7 // e7036538 LDCLRAD R5, (R6), R7 // c710a5f8 LDCLRAD R5, (RSP), R7 // e713a5f8 LDCLRAW R5, (R6), R7 // c710a5b8 LDCLRAW R5, (RSP), R7 // e713a5b8 LDCLRAH R5, (R6), R7 // c710a578 LDCLRAH R5, (RSP), R7 // e713a578 LDCLRAB R5, (R6), R7 // c710a538 LDCLRAB R5, (RSP), R7 // e713a538 LDCLRALD R5, (R6), R7 // c710e5f8 LDCLRALD R5, (RSP), R7 // e713e5f8 LDCLRALW R5, (R6), R7 // c710e5b8 LDCLRALW R5, (RSP), R7 // e713e5b8 LDCLRALH R5, (R6), R7 // c710e578 LDCLRALH R5, (RSP), R7 // e713e578 LDCLRALB R5, (R6), R7 // c710e538 LDCLRALB R5, (RSP), R7 // e713e538 LDCLRD R5, (R6), R7 // c71025f8 LDCLRD R5, (RSP), R7 // e71325f8 LDCLRW R5, (R6), R7 // c71025b8 LDCLRW R5, (RSP), R7 // e71325b8 LDCLRH R5, (R6), R7 // c7102578 LDCLRH R5, (RSP), R7 // e7132578 LDCLRB R5, (R6), R7 // c7102538 LDCLRB R5, (RSP), R7 // e7132538 LDCLRLD R5, (R6), R7 // c71065f8 LDCLRLD R5, (RSP), R7 // e71365f8 LDCLRLW R5, (R6), R7 // c71065b8 LDCLRLW R5, (RSP), R7 // e71365b8 LDCLRLH R5, (R6), R7 // c7106578 LDCLRLH R5, (RSP), R7 // e7136578 LDCLRLB R5, (R6), R7 // c7106538 LDCLRLB R5, (RSP), R7 // e7136538 LDEORAD R5, (R6), R7 // c720a5f8 LDEORAD R5, (RSP), R7 // e723a5f8 LDEORAW R5, (R6), R7 // c720a5b8 LDEORAW R5, (RSP), R7 // e723a5b8 LDEORAH R5, (R6), R7 // c720a578 LDEORAH R5, (RSP), R7 // e723a578 LDEORAB R5, (R6), R7 // c720a538 LDEORAB R5, (RSP), R7 // e723a538 LDEORALD R5, (R6), R7 // c720e5f8 LDEORALD R5, (RSP), R7 // e723e5f8 LDEORALW R5, (R6), R7 // c720e5b8 LDEORALW R5, (RSP), R7 // e723e5b8 LDEORALH R5, (R6), R7 // c720e578 LDEORALH R5, (RSP), R7 // e723e578 LDEORALB R5, (R6), R7 // c720e538 LDEORALB R5, (RSP), R7 // e723e538 LDEORD R5, (R6), R7 // c72025f8 LDEORD R5, (RSP), R7 // e72325f8 LDEORW R5, (R6), R7 // c72025b8 LDEORW R5, (RSP), R7 // e72325b8 LDEORH R5, (R6), R7 // c7202578 LDEORH R5, (RSP), R7 // e7232578 LDEORB R5, (R6), R7 // c7202538 LDEORB R5, (RSP), R7 // e7232538 LDEORLD R5, (R6), R7 // c72065f8 LDEORLD R5, (RSP), R7 // e72365f8 LDEORLW R5, (R6), R7 // c72065b8 LDEORLW R5, (RSP), R7 // e72365b8 LDEORLH R5, (R6), R7 // c7206578 LDEORLH R5, (RSP), R7 // e7236578 LDEORLB R5, (R6), R7 // c7206538 LDEORLB R5, (RSP), R7 // e7236538 LDADDD R5, (R6), ZR // df0025f8 LDADDW R5, (R6), ZR // df0025b8 LDADDH R5, (R6), ZR // df002578 LDADDB R5, (R6), ZR // df002538 LDADDLD R5, (R6), ZR // df0065f8 LDADDLW R5, (R6), ZR // df0065b8 LDADDLH R5, (R6), ZR // df006578 LDADDLB R5, (R6), ZR // df006538 LDCLRD R5, (R6), ZR // df1025f8 LDCLRW R5, (R6), ZR // df1025b8 LDCLRH R5, (R6), ZR // df102578 LDCLRB R5, (R6), ZR // df102538 LDCLRLD R5, (R6), ZR // df1065f8 LDCLRLW R5, (R6), ZR // df1065b8 LDCLRLH R5, (R6), ZR // df106578 LDCLRLB R5, (R6), ZR // df106538 LDEORD R5, (R6), ZR // df2025f8 LDEORW R5, (R6), ZR // df2025b8 LDEORH R5, (R6), ZR // df202578 LDEORB R5, (R6), ZR // df202538 LDEORLD R5, (R6), ZR // df2065f8 LDEORLW R5, (R6), ZR // df2065b8 LDEORLH R5, (R6), ZR // df206578 LDEORLB R5, (R6), ZR // df206538 LDORD R5, (R6), ZR // df3025f8 LDORW R5, (R6), ZR // df3025b8 LDORH R5, (R6), ZR // df302578 LDORB R5, (R6), ZR // df302538 LDORLD R5, (R6), ZR // df3065f8 LDORLW R5, (R6), ZR // df3065b8 LDORLH R5, (R6), ZR // df306578 LDORLB R5, (R6), ZR // df306538 LDORAD R5, (R6), R7 // c730a5f8 LDORAD R5, (RSP), R7 // e733a5f8 LDORAW R5, (R6), R7 // c730a5b8 LDORAW R5, (RSP), R7 // e733a5b8 LDORAH R5, (R6), R7 // c730a578 LDORAH R5, (RSP), R7 // e733a578 LDORAB R5, (R6), R7 // c730a538 LDORAB R5, (RSP), R7 // e733a538 LDORALD R5, (R6), R7 // c730e5f8 LDORALD R5, (RSP), R7 // e733e5f8 LDORALW R5, (R6), R7 // c730e5b8 LDORALW R5, (RSP), R7 // e733e5b8 LDORALH R5, (R6), R7 // c730e578 LDORALH R5, (RSP), R7 // e733e578 LDORALB R5, (R6), R7 // c730e538 LDORALB R5, (RSP), R7 // e733e538 LDORD R5, (R6), R7 // c73025f8 LDORD R5, (RSP), R7 // e73325f8 LDORW R5, (R6), R7 // c73025b8 LDORW R5, (RSP), R7 // e73325b8 LDORH R5, (R6), R7 // c7302578 LDORH R5, (RSP), R7 // e7332578 LDORB R5, (R6), R7 // c7302538 LDORB R5, (RSP), R7 // e7332538 LDORLD R5, (R6), R7 // c73065f8 LDORLD R5, (RSP), R7 // e73365f8 LDORLW R5, (R6), R7 // c73065b8 LDORLW R5, (RSP), R7 // e73365b8 LDORLH R5, (R6), R7 // c7306578 LDORLH R5, (RSP), R7 // e7336578 LDORLB R5, (R6), R7 // c7306538 LDORLB R5, (RSP), R7 // e7336538 CASD R1, (R2), ZR // 5f7ca1c8 CASW R1, (RSP), ZR // ff7fa188 CASB ZR, (R5), R3 // a37cbf08 CASH R3, (RSP), ZR // ff7fa348 CASW R5, (R7), R6 // e67ca588 CASLD ZR, (RSP), R8 // e8ffbfc8 CASLW R9, (R10), ZR // 5ffda988 CASAD R7, (R11), R15 // 6f7de7c8 CASAW R10, (RSP), R19 // f37fea88 CASALD R5, (R6), R7 // c7fce5c8 CASALD R5, (RSP), R7 // e7ffe5c8 CASALW R5, (R6), R7 // c7fce588 CASALW R5, (RSP), R7 // e7ffe588 CASALH ZR, (R5), R8 // a8fcff48 CASALB R8, (R9), ZR // 3ffde808 CASPD (R30, ZR), (RSP), (R8, R9) // e87f3e48 CASPW (R6, R7), (R8), (R4, R5) // 047d2608 CASPD (R2, R3), (R2), (R8, R9) // 487c2248 // RET RET // c0035fd6 RET R0 // 00005fd6 RET R6 // c0005fd6 RET R27 // 60035fd6 RET R30 // c0035fd6 RET foo(SB) // B/BL/B.cond cases, and canonical names JMP, CALL. BL 1(PC) // CALL 1(PC) BL (R2) // CALL (R2) BL foo(SB) // CALL foo(SB) BL bar<>(SB) // CALL bar<>(SB) B foo(SB) // JMP foo(SB) BEQ 1(PC) BEQ 2(PC) TBZ $1, R1, 2(PC) TBNZ $2, R2, 2(PC) JMP foo(SB) CALL foo(SB) // ADR ADR next, R11 // ADR R11 // 2b000010 next: NOP ADR -2(PC), R10 // 0a000010 ADR 2(PC), R16 // 10000010 ADR -26(PC), R1 // 01000010 ADR 12(PC), R2 // 02000010 ADRP -2(PC), R10 // 0a000090 ADRP 2(PC), R16 // 10000090 ADRP -26(PC), R1 // 01000090 ADRP 12(PC), R2 // 02000090 // LDP/STP LDP (R0), (R0, R1) // 000440a9 LDP (R0), (R1, R2) // 010840a9 LDP 8(R0), (R1, R2) // 018840a9 LDP -8(R0), (R1, R2) // 01887fa9 LDP 11(R0), (R1, R2) // 1b2c0091610b40a9 LDP 1024(R0), (R1, R2) // 1b001091610b40a9 LDP.W 8(R0), (R1, R2) // 0188c0a9 LDP.P 8(R0), (R1, R2) // 0188c0a8 LDP (RSP), (R1, R2) // e10b40a9 LDP 8(RSP), (R1, R2) // e18b40a9 LDP -8(RSP), (R1, R2) // e18b7fa9 LDP 11(RSP), (R1, R2) // fb2f0091610b40a9 LDP 1024(RSP), (R1, R2) // fb031091610b40a9 LDP.W 8(RSP), (R1, R2) // e18bc0a9 LDP.P 8(RSP), (R1, R2) // e18bc0a8 LDP -31(R0), (R1, R2) // 1b7c00d1610b40a9 LDP -4(R0), (R1, R2) // 1b1000d1610b40a9 LDP -8(R0), (R1, R2) // 01887fa9 LDP x(SB), (R1, R2) LDP x+8(SB), (R1, R2) LDP 8(R1), (ZR, R2) // 3f8840a9 LDPW -5(R0), (R1, R2) // 1b1400d1610b4029 LDPW (R0), (R1, R2) // 01084029 LDPW 4(R0), (R1, R2) // 01884029 LDPW -4(R0), (R1, R2) // 01887f29 LDPW.W 4(R0), (R1, R2) // 0188c029 LDPW.P 4(R0), (R1, R2) // 0188c028 LDPW 11(R0), (R1, R2) // 1b2c0091610b4029 LDPW 1024(R0), (R1, R2) // 1b001091610b4029 LDPW (RSP), (R1, R2) // e10b4029 LDPW 4(RSP), (R1, R2) // e18b4029 LDPW -4(RSP), (R1, R2) // e18b7f29 LDPW.W 4(RSP), (R1, R2) // e18bc029 LDPW.P 4(RSP), (R1, R2) // e18bc028 LDPW 11(RSP), (R1, R2) // fb2f0091610b4029 LDPW 1024(RSP), (R1, R2) // fb031091610b4029 LDPW x(SB), (R1, R2) LDPW x+8(SB), (R1, R2) LDPW 8(R1), (ZR, R2) // 3f084129 LDPSW (R0), (R1, R2) // 01084069 LDPSW 4(R0), (R1, R2) // 01884069 LDPSW -4(R0), (R1, R2) // 01887f69 LDPSW.W 4(R0), (R1, R2) // 0188c069 LDPSW.P 4(R0), (R1, R2) // 0188c068 LDPSW 11(R0), (R1, R2) // 1b2c0091610b4069 LDPSW 1024(R0), (R1, R2) // 1b001091610b4069 LDPSW (RSP), (R1, R2) // e10b4069 LDPSW 4(RSP), (R1, R2) // e18b4069 LDPSW -4(RSP), (R1, R2) // e18b7f69 LDPSW.W 4(RSP), (R1, R2) // e18bc069 LDPSW.P 4(RSP), (R1, R2) // e18bc068 LDPSW 11(RSP), (R1, R2) // fb2f0091610b4069 LDPSW 1024(RSP), (R1, R2) // fb031091610b4069 LDPSW x(SB), (R1, R2) LDPSW x+8(SB), (R1, R2) LDPSW 8(R1), (ZR, R2) // 3f084169 STP (R3, R4), (R5) // a31000a9 STP (R3, R4), 8(R5) // a39000a9 STP.W (R3, R4), 8(R5) // a39080a9 STP.P (R3, R4), 8(R5) // a39080a8 STP (R3, R4), -8(R5) // a3903fa9 STP (R3, R4), -4(R5) // bb1000d1631300a9 STP (R3, R4), 11(R0) // 1b2c0091631300a9 STP (R3, R4), 1024(R0) // 1b001091631300a9 STP (R3, R4), (RSP) // e31300a9 STP (R3, R4), 8(RSP) // e39300a9 STP.W (R3, R4), 8(RSP) // e39380a9 STP.P (R3, R4), 8(RSP) // e39380a8 STP (R3, R4), -8(RSP) // e3933fa9 STP (R3, R4), 11(RSP) // fb2f0091631300a9 STP (R3, R4), 1024(RSP) // fb031091631300a9 STP (R3, R4), x(SB) STP (R3, R4), x+8(SB) STPW (R3, R4), (R5) // a3100029 STPW (R3, R4), 4(R5) // a3900029 STPW.W (R3, R4), 4(R5) // a3908029 STPW.P (R3, R4), 4(R5) // a3908028 STPW (R3, R4), -4(R5) // a3903f29 STPW (R3, R4), -5(R5) // bb1400d163130029 STPW (R3, R4), 11(R0) // 1b2c009163130029 STPW (R3, R4), 1024(R0) // 1b00109163130029 STPW (R3, R4), (RSP) // e3130029 STPW (R3, R4), 4(RSP) // e3930029 STPW.W (R3, R4), 4(RSP) // e3938029 STPW.P (R3, R4), 4(RSP) // e3938028 STPW (R3, R4), -4(RSP) // e3933f29 STPW (R3, R4), 11(RSP) // fb2f009163130029 STPW (R3, R4), 1024(RSP) // fb03109163130029 STPW (R3, R4), x(SB) STPW (R3, R4), x+8(SB) // bit field operation BFI $0, R1, $1, R2 // 220040b3 BFIW $0, R1, $1, R2 // 22000033 SBFIZ $0, R1, $1, R2 // 22004093 SBFIZW $0, R1, $1, R2 // 22000013 UBFIZ $0, R1, $1, R2 // 220040d3 UBFIZW $0, R1, $1, R2 // 22000053 // FSTPD/FSTPS/FLDPD/FLDPS FLDPD (R0), (F1, F2) // 0108406d FLDPD 8(R0), (F1, F2) // 0188406d FLDPD -8(R0), (F1, F2) // 01887f6d FLDPD 11(R0), (F1, F2) // 1b2c0091610b406d FLDPD 1024(R0), (F1, F2) // 1b001091610b406d FLDPD.W 8(R0), (F1, F2) // 0188c06d FLDPD.P 8(R0), (F1, F2) // 0188c06c FLDPD (RSP), (F1, F2) // e10b406d FLDPD 8(RSP), (F1, F2) // e18b406d FLDPD -8(RSP), (F1, F2) // e18b7f6d FLDPD 11(RSP), (F1, F2) // fb2f0091610b406d FLDPD 1024(RSP), (F1, F2) // fb031091610b406d FLDPD.W 8(RSP), (F1, F2) // e18bc06d FLDPD.P 8(RSP), (F1, F2) // e18bc06c FLDPD -31(R0), (F1, F2) // 1b7c00d1610b406d FLDPD -4(R0), (F1, F2) // 1b1000d1610b406d FLDPD -8(R0), (F1, F2) // 01887f6d FLDPD x(SB), (F1, F2) FLDPD x+8(SB), (F1, F2) FLDPS -5(R0), (F1, F2) // 1b1400d1610b402d FLDPS (R0), (F1, F2) // 0108402d FLDPS 4(R0), (F1, F2) // 0188402d FLDPS -4(R0), (F1, F2) // 01887f2d FLDPS.W 4(R0), (F1, F2) // 0188c02d FLDPS.P 4(R0), (F1, F2) // 0188c02c FLDPS 11(R0), (F1, F2) // 1b2c0091610b402d FLDPS 1024(R0), (F1, F2) // 1b001091610b402d FLDPS (RSP), (F1, F2) // e10b402d FLDPS 4(RSP), (F1, F2) // e18b402d FLDPS -4(RSP), (F1, F2) // e18b7f2d FLDPS.W 4(RSP), (F1, F2) // e18bc02d FLDPS.P 4(RSP), (F1, F2) // e18bc02c FLDPS 11(RSP), (F1, F2) // fb2f0091610b402d FLDPS 1024(RSP), (F1, F2) // fb031091610b402d FLDPS x(SB), (F1, F2) FLDPS x+8(SB), (F1, F2) FSTPD (F3, F4), (R5) // a310006d FSTPD (F3, F4), 8(R5) // a390006d FSTPD.W (F3, F4), 8(R5) // a390806d FSTPD.P (F3, F4), 8(R5) // a390806c FSTPD (F3, F4), -8(R5) // a3903f6d FSTPD (F3, F4), -4(R5) // bb1000d16313006d FSTPD (F3, F4), 11(R0) // 1b2c00916313006d FSTPD (F3, F4), 1024(R0) // 1b0010916313006d FSTPD (F3, F4), (RSP) // e313006d FSTPD (F3, F4), 8(RSP) // e393006d FSTPD.W (F3, F4), 8(RSP) // e393806d FSTPD.P (F3, F4), 8(RSP) // e393806c FSTPD (F3, F4), -8(RSP) // e3933f6d FSTPD (F3, F4), 11(RSP) // fb2f00916313006d FSTPD (F3, F4), 1024(RSP) // fb0310916313006d FSTPD (F3, F4), x(SB) FSTPD (F3, F4), x+8(SB) FSTPS (F3, F4), (R5) // a310002d FSTPS (F3, F4), 4(R5) // a390002d FSTPS.W (F3, F4), 4(R5) // a390802d FSTPS.P (F3, F4), 4(R5) // a390802c FSTPS (F3, F4), -4(R5) // a3903f2d FSTPS (F3, F4), -5(R5) // bb1400d16313002d FSTPS (F3, F4), 11(R0) // 1b2c00916313002d FSTPS (F3, F4), 1024(R0) // 1b0010916313002d FSTPS (F3, F4), (RSP) // e313002d FSTPS (F3, F4), 4(RSP) // e393002d FSTPS.W (F3, F4), 4(RSP) // e393802d FSTPS.P (F3, F4), 4(RSP) // e393802c FSTPS (F3, F4), -4(RSP) // e3933f2d FSTPS (F3, F4), 11(RSP) // fb2f00916313002d FSTPS (F3, F4), 1024(RSP) // fb0310916313002d FSTPS (F3, F4), x(SB) FSTPS (F3, F4), x+8(SB) // FLDPQ/FSTPQ FLDPQ -4000(R0), (F1, F2) // 1b803ed1610b40ad FLDPQ -1024(R0), (F1, F2) // 010860ad FLDPQ (R0), (F1, F2) // 010840ad FLDPQ 16(R0), (F1, F2) // 018840ad FLDPQ -16(R0), (F1, F2) // 01887fad FLDPQ.W 32(R0), (F1, F2) // 0108c1ad FLDPQ.P 32(R0), (F1, F2) // 0108c1ac FLDPQ 11(R0), (F1, F2) // 1b2c0091610b40ad FLDPQ 1024(R0), (F1, F2) // 1b001091610b40ad FLDPQ 4104(R0), (F1, F2) FLDPQ -4000(RSP), (F1, F2) // fb833ed1610b40ad FLDPQ -1024(RSP), (F1, F2) // e10b60ad FLDPQ (RSP), (F1, F2) // e10b40ad FLDPQ 16(RSP), (F1, F2) // e18b40ad FLDPQ -16(RSP), (F1, F2) // e18b7fad FLDPQ.W 32(RSP), (F1, F2) // e10bc1ad FLDPQ.P 32(RSP), (F1, F2) // e10bc1ac FLDPQ 11(RSP), (F1, F2) // fb2f0091610b40ad FLDPQ 1024(RSP), (F1, F2) // fb031091610b40ad FLDPQ 4104(RSP), (F1, F2) FLDPQ -31(R0), (F1, F2) // 1b7c00d1610b40ad FLDPQ -4(R0), (F1, F2) // 1b1000d1610b40ad FLDPQ x(SB), (F1, F2) FLDPQ x+8(SB), (F1, F2) FSTPQ (F3, F4), -4000(R5) // bb803ed1631300ad FSTPQ (F3, F4), -1024(R5) // a31020ad FSTPQ (F3, F4), (R5) // a31000ad FSTPQ (F3, F4), 16(R5) // a39000ad FSTPQ (F3, F4), -16(R5) // a3903fad FSTPQ.W (F3, F4), 32(R5) // a31081ad FSTPQ.P (F3, F4), 32(R5) // a31081ac FSTPQ (F3, F4), 11(R5) // bb2c0091631300ad FSTPQ (F3, F4), 1024(R5) // bb001091631300ad FSTPQ (F3, F4), 4104(R5) FSTPQ (F3, F4), -4000(RSP) // fb833ed1631300ad FSTPQ (F3, F4), -1024(RSP) // e31320ad FSTPQ (F3, F4), (RSP) // e31300ad FSTPQ (F3, F4), 16(RSP) // e39300ad FSTPQ (F3, F4), -16(RSP) // e3933fad FSTPQ.W (F3, F4), 32(RSP) // e31381ad FSTPQ.P (F3, F4), 32(RSP) // e31381ac FSTPQ (F3, F4), 11(RSP) // fb2f0091631300ad FSTPQ (F3, F4), 1024(RSP) // fb031091631300ad FSTPQ (F3, F4), 4104(RSP) FSTPQ (F3, F4), x(SB) FSTPQ (F3, F4), x+8(SB) // System Register MSR $1, SPSel // bf4100d5 MSR $9, DAIFSet // df4903d5 MSR $6, DAIFClr // ff4603d5 MSR $0, CPACR_EL1 // 5f1018d5 MRS ELR_EL1, R8 // 284038d5 MSR R16, ELR_EL1 // 304018d5 MSR R2, ACTLR_EL1 // 221018d5 MRS TCR_EL1, R5 // 452038d5 MRS PMEVCNTR15_EL0, R12 // ece93bd5 MSR R20, PMEVTYPER26_EL0 // 54ef1bd5 MSR R10, DBGBCR15_EL1 // aa0f10d5 MRS ACTLR_EL1, R3 // 231038d5 MSR R9, ACTLR_EL1 // 291018d5 MRS AFSR0_EL1, R10 // 0a5138d5 MSR R1, AFSR0_EL1 // 015118d5 MRS AFSR0_EL1, R9 // 095138d5 MSR R30, AFSR0_EL1 // 1e5118d5 MRS AFSR1_EL1, R0 // 205138d5 MSR R1, AFSR1_EL1 // 215118d5 MRS AFSR1_EL1, R8 // 285138d5 MSR R19, AFSR1_EL1 // 335118d5 MRS AIDR_EL1, R11 // eb0039d5 MRS AMAIR_EL1, R0 // 00a338d5 MSR R22, AMAIR_EL1 // 16a318d5 MRS AMAIR_EL1, R14 // 0ea338d5 MSR R0, AMAIR_EL1 // 00a318d5 MRS APDAKeyHi_EL1, R16 // 302238d5 MSR R26, APDAKeyHi_EL1 // 3a2218d5 MRS APDAKeyLo_EL1, R21 // 152238d5 MSR R22, APDAKeyLo_EL1 // 162218d5 MRS APDBKeyHi_EL1, R2 // 622238d5 MSR R6, APDBKeyHi_EL1 // 662218d5 MRS APDBKeyLo_EL1, R5 // 452238d5 MSR R22, APDBKeyLo_EL1 // 562218d5 MRS APGAKeyHi_EL1, R22 // 362338d5 MSR R5, APGAKeyHi_EL1 // 252318d5 MRS APGAKeyLo_EL1, R16 // 102338d5 MSR R22, APGAKeyLo_EL1 // 162318d5 MRS APIAKeyHi_EL1, R23 // 372138d5 MSR R17, APIAKeyHi_EL1 // 312118d5 MRS APIAKeyLo_EL1, R16 // 102138d5 MSR R6, APIAKeyLo_EL1 // 062118d5 MRS APIBKeyHi_EL1, R10 // 6a2138d5 MSR R11, APIBKeyHi_EL1 // 6b2118d5 MRS APIBKeyLo_EL1, R25 // 592138d5 MSR R22, APIBKeyLo_EL1 // 562118d5 MRS CCSIDR_EL1, R25 // 190039d5 MRS CLIDR_EL1, R16 // 300039d5 MRS CNTFRQ_EL0, R20 // 14e03bd5 MSR R16, CNTFRQ_EL0 // 10e01bd5 MRS CNTKCTL_EL1, R26 // 1ae138d5 MSR R0, CNTKCTL_EL1 // 00e118d5 MRS CNTP_CTL_EL0, R14 // 2ee23bd5 MSR R17, CNTP_CTL_EL0 // 31e21bd5 MRS CNTP_CVAL_EL0, R15 // 4fe23bd5 MSR R8, CNTP_CVAL_EL0 // 48e21bd5 MRS CNTP_TVAL_EL0, R6 // 06e23bd5 MSR R29, CNTP_TVAL_EL0 // 1de21bd5 MRS CNTP_CTL_EL0, R22 // 36e23bd5 MSR R0, CNTP_CTL_EL0 // 20e21bd5 MRS CNTP_CVAL_EL0, R9 // 49e23bd5 MSR R4, CNTP_CVAL_EL0 // 44e21bd5 MRS CNTP_TVAL_EL0, R27 // 1be23bd5 MSR R17, CNTP_TVAL_EL0 // 11e21bd5 MRS CNTV_CTL_EL0, R27 // 3be33bd5 MSR R2, CNTV_CTL_EL0 // 22e31bd5 MRS CNTV_CVAL_EL0, R16 // 50e33bd5 MSR R27, CNTV_CVAL_EL0 // 5be31bd5 MRS CNTV_TVAL_EL0, R12 // 0ce33bd5 MSR R19, CNTV_TVAL_EL0 // 13e31bd5 MRS CNTV_CTL_EL0, R14 // 2ee33bd5 MSR R2, CNTV_CTL_EL0 // 22e31bd5 MRS CNTV_CVAL_EL0, R8 // 48e33bd5 MSR R26, CNTV_CVAL_EL0 // 5ae31bd5 MRS CNTV_TVAL_EL0, R6 // 06e33bd5 MSR R19, CNTV_TVAL_EL0 // 13e31bd5 MRS CNTKCTL_EL1, R16 // 10e138d5 MSR R26, CNTKCTL_EL1 // 1ae118d5 MRS CNTPCT_EL0, R9 // 29e03bd5 MRS CNTPS_CTL_EL1, R30 // 3ee23fd5 MSR R26, CNTPS_CTL_EL1 // 3ae21fd5 MRS CNTPS_CVAL_EL1, R8 // 48e23fd5 MSR R26, CNTPS_CVAL_EL1 // 5ae21fd5 MRS CNTPS_TVAL_EL1, R7 // 07e23fd5 MSR R13, CNTPS_TVAL_EL1 // 0de21fd5 MRS CNTP_CTL_EL0, R2 // 22e23bd5 MSR R10, CNTP_CTL_EL0 // 2ae21bd5 MRS CNTP_CVAL_EL0, R6 // 46e23bd5 MSR R21, CNTP_CVAL_EL0 // 55e21bd5 MRS CNTP_TVAL_EL0, R27 // 1be23bd5 MSR R29, CNTP_TVAL_EL0 // 1de21bd5 MRS CNTVCT_EL0, R13 // 4de03bd5 MRS CNTV_CTL_EL0, R30 // 3ee33bd5 MSR R19, CNTV_CTL_EL0 // 33e31bd5 MRS CNTV_CVAL_EL0, R27 // 5be33bd5 MSR R24, CNTV_CVAL_EL0 // 58e31bd5 MRS CNTV_TVAL_EL0, R24 // 18e33bd5 MSR R5, CNTV_TVAL_EL0 // 05e31bd5 MRS CONTEXTIDR_EL1, R15 // 2fd038d5 MSR R27, CONTEXTIDR_EL1 // 3bd018d5 MRS CONTEXTIDR_EL1, R29 // 3dd038d5 MSR R24, CONTEXTIDR_EL1 // 38d018d5 MRS CPACR_EL1, R10 // 4a1038d5 MSR R14, CPACR_EL1 // 4e1018d5 MRS CPACR_EL1, R27 // 5b1038d5 MSR R22, CPACR_EL1 // 561018d5 MRS CSSELR_EL1, R3 // 03003ad5 MSR R4, CSSELR_EL1 // 04001ad5 MRS CTR_EL0, R15 // 2f003bd5 MRS CurrentEL, R1 // 414238d5 MRS DAIF, R24 // 38423bd5 MSR R9, DAIF // 29421bd5 MRS DBGAUTHSTATUS_EL1, R5 // c57e30d5 MRS DBGBCR0_EL1, R29 // bd0030d5 MRS DBGBCR1_EL1, R13 // ad0130d5 MRS DBGBCR2_EL1, R22 // b60230d5 MRS DBGBCR3_EL1, R8 // a80330d5 MRS DBGBCR4_EL1, R2 // a20430d5 MRS DBGBCR5_EL1, R4 // a40530d5 MRS DBGBCR6_EL1, R2 // a20630d5 MRS DBGBCR7_EL1, R6 // a60730d5 MRS DBGBCR8_EL1, R1 // a10830d5 MRS DBGBCR9_EL1, R16 // b00930d5 MRS DBGBCR10_EL1, R23 // b70a30d5 MRS DBGBCR11_EL1, R3 // a30b30d5 MRS DBGBCR12_EL1, R6 // a60c30d5 MRS DBGBCR13_EL1, R16 // b00d30d5 MRS DBGBCR14_EL1, R4 // a40e30d5 MRS DBGBCR15_EL1, R9 // a90f30d5 MSR R4, DBGBCR0_EL1 // a40010d5 MSR R14, DBGBCR1_EL1 // ae0110d5 MSR R7, DBGBCR2_EL1 // a70210d5 MSR R12, DBGBCR3_EL1 // ac0310d5 MSR R6, DBGBCR4_EL1 // a60410d5 MSR R11, DBGBCR5_EL1 // ab0510d5 MSR R6, DBGBCR6_EL1 // a60610d5 MSR R13, DBGBCR7_EL1 // ad0710d5 MSR R17, DBGBCR8_EL1 // b10810d5 MSR R17, DBGBCR9_EL1 // b10910d5 MSR R22, DBGBCR10_EL1 // b60a10d5 MSR R16, DBGBCR11_EL1 // b00b10d5 MSR R24, DBGBCR12_EL1 // b80c10d5 MSR R29, DBGBCR13_EL1 // bd0d10d5 MSR R1, DBGBCR14_EL1 // a10e10d5 MSR R10, DBGBCR15_EL1 // aa0f10d5 MRS DBGBVR0_EL1, R16 // 900030d5 MRS DBGBVR1_EL1, R21 // 950130d5 MRS DBGBVR2_EL1, R13 // 8d0230d5 MRS DBGBVR3_EL1, R12 // 8c0330d5 MRS DBGBVR4_EL1, R20 // 940430d5 MRS DBGBVR5_EL1, R21 // 950530d5 MRS DBGBVR6_EL1, R27 // 9b0630d5 MRS DBGBVR7_EL1, R6 // 860730d5 MRS DBGBVR8_EL1, R14 // 8e0830d5 MRS DBGBVR9_EL1, R5 // 850930d5 MRS DBGBVR10_EL1, R9 // 890a30d5 MRS DBGBVR11_EL1, R25 // 990b30d5 MRS DBGBVR12_EL1, R30 // 9e0c30d5 MRS DBGBVR13_EL1, R1 // 810d30d5 MRS DBGBVR14_EL1, R17 // 910e30d5 MRS DBGBVR15_EL1, R25 // 990f30d5 MSR R15, DBGBVR0_EL1 // 8f0010d5 MSR R6, DBGBVR1_EL1 // 860110d5 MSR R24, DBGBVR2_EL1 // 980210d5 MSR R17, DBGBVR3_EL1 // 910310d5 MSR R3, DBGBVR4_EL1 // 830410d5 MSR R21, DBGBVR5_EL1 // 950510d5 MSR R5, DBGBVR6_EL1 // 850610d5 MSR R6, DBGBVR7_EL1 // 860710d5 MSR R25, DBGBVR8_EL1 // 990810d5 MSR R4, DBGBVR9_EL1 // 840910d5 MSR R25, DBGBVR10_EL1 // 990a10d5 MSR R17, DBGBVR11_EL1 // 910b10d5 MSR R0, DBGBVR12_EL1 // 800c10d5 MSR R5, DBGBVR13_EL1 // 850d10d5 MSR R9, DBGBVR14_EL1 // 890e10d5 MSR R12, DBGBVR15_EL1 // 8c0f10d5 MRS DBGCLAIMCLR_EL1, R27 // db7930d5 MSR R0, DBGCLAIMCLR_EL1 // c07910d5 MRS DBGCLAIMSET_EL1, R7 // c77830d5 MSR R13, DBGCLAIMSET_EL1 // cd7810d5 MRS DBGDTRRX_EL0, R0 // 000533d5 MSR R29, DBGDTRTX_EL0 // 1d0513d5 MRS DBGDTR_EL0, R27 // 1b0433d5 MSR R30, DBGDTR_EL0 // 1e0413d5 MRS DBGPRCR_EL1, R4 // 841430d5 MSR R0, DBGPRCR_EL1 // 801410d5 MRS DBGWCR0_EL1, R24 // f80030d5 MRS DBGWCR1_EL1, R19 // f30130d5 MRS DBGWCR2_EL1, R25 // f90230d5 MRS DBGWCR3_EL1, R0 // e00330d5 MRS DBGWCR4_EL1, R13 // ed0430d5 MRS DBGWCR5_EL1, R8 // e80530d5 MRS DBGWCR6_EL1, R22 // f60630d5 MRS DBGWCR7_EL1, R11 // eb0730d5 MRS DBGWCR8_EL1, R11 // eb0830d5 MRS DBGWCR9_EL1, R3 // e30930d5 MRS DBGWCR10_EL1, R17 // f10a30d5 MRS DBGWCR11_EL1, R21 // f50b30d5 MRS DBGWCR12_EL1, R10 // ea0c30d5 MRS DBGWCR13_EL1, R22 // f60d30d5 MRS DBGWCR14_EL1, R11 // eb0e30d5 MRS DBGWCR15_EL1, R0 // e00f30d5 MSR R24, DBGWCR0_EL1 // f80010d5 MSR R8, DBGWCR1_EL1 // e80110d5 MSR R17, DBGWCR2_EL1 // f10210d5 MSR R29, DBGWCR3_EL1 // fd0310d5 MSR R13, DBGWCR4_EL1 // ed0410d5 MSR R22, DBGWCR5_EL1 // f60510d5 MSR R3, DBGWCR6_EL1 // e30610d5 MSR R4, DBGWCR7_EL1 // e40710d5 MSR R7, DBGWCR8_EL1 // e70810d5 MSR R29, DBGWCR9_EL1 // fd0910d5 MSR R3, DBGWCR10_EL1 // e30a10d5 MSR R11, DBGWCR11_EL1 // eb0b10d5 MSR R20, DBGWCR12_EL1 // f40c10d5 MSR R6, DBGWCR13_EL1 // e60d10d5 MSR R22, DBGWCR14_EL1 // f60e10d5 MSR R25, DBGWCR15_EL1 // f90f10d5 MRS DBGWVR0_EL1, R14 // ce0030d5 MRS DBGWVR1_EL1, R16 // d00130d5 MRS DBGWVR2_EL1, R15 // cf0230d5 MRS DBGWVR3_EL1, R1 // c10330d5 MRS DBGWVR4_EL1, R26 // da0430d5 MRS DBGWVR5_EL1, R14 // ce0530d5 MRS DBGWVR6_EL1, R17 // d10630d5 MRS DBGWVR7_EL1, R22 // d60730d5 MRS DBGWVR8_EL1, R4 // c40830d5 MRS DBGWVR9_EL1, R3 // c30930d5 MRS DBGWVR10_EL1, R16 // d00a30d5 MRS DBGWVR11_EL1, R2 // c20b30d5 MRS DBGWVR12_EL1, R5 // c50c30d5 MRS DBGWVR13_EL1, R23 // d70d30d5 MRS DBGWVR14_EL1, R5 // c50e30d5 MRS DBGWVR15_EL1, R6 // c60f30d5 MSR R24, DBGWVR0_EL1 // d80010d5 MSR R6, DBGWVR1_EL1 // c60110d5 MSR R1, DBGWVR2_EL1 // c10210d5 MSR R24, DBGWVR3_EL1 // d80310d5 MSR R24, DBGWVR4_EL1 // d80410d5 MSR R0, DBGWVR5_EL1 // c00510d5 MSR R10, DBGWVR6_EL1 // ca0610d5 MSR R17, DBGWVR7_EL1 // d10710d5 MSR R7, DBGWVR8_EL1 // c70810d5 MSR R8, DBGWVR9_EL1 // c80910d5 MSR R15, DBGWVR10_EL1 // cf0a10d5 MSR R8, DBGWVR11_EL1 // c80b10d5 MSR R7, DBGWVR12_EL1 // c70c10d5 MSR R14, DBGWVR13_EL1 // ce0d10d5 MSR R16, DBGWVR14_EL1 // d00e10d5 MSR R5, DBGWVR15_EL1 // c50f10d5 MRS DCZID_EL0, R21 // f5003bd5 MRS DISR_EL1, R8 // 28c138d5 MSR R5, DISR_EL1 // 25c118d5 MRS DIT, R29 // bd423bd5 MSR R22, DIT // b6421bd5 MRS DLR_EL0, R25 // 39453bd5 MSR R9, DLR_EL0 // 29451bd5 MRS DSPSR_EL0, R3 // 03453bd5 MSR R10, DSPSR_EL0 // 0a451bd5 MRS ELR_EL1, R24 // 384038d5 MSR R3, ELR_EL1 // 234018d5 MRS ELR_EL1, R13 // 2d4038d5 MSR R27, ELR_EL1 // 3b4018d5 MRS ERRIDR_EL1, R30 // 1e5338d5 MRS ERRSELR_EL1, R21 // 355338d5 MSR R22, ERRSELR_EL1 // 365318d5 MRS ERXADDR_EL1, R30 // 7e5438d5 MSR R0, ERXADDR_EL1 // 605418d5 MRS ERXCTLR_EL1, R6 // 265438d5 MSR R9, ERXCTLR_EL1 // 295418d5 MRS ERXFR_EL1, R19 // 135438d5 MRS ERXMISC0_EL1, R20 // 145538d5 MSR R24, ERXMISC0_EL1 // 185518d5 MRS ERXMISC1_EL1, R15 // 2f5538d5 MSR R10, ERXMISC1_EL1 // 2a5518d5 MRS ERXSTATUS_EL1, R30 // 5e5438d5 MSR R3, ERXSTATUS_EL1 // 435418d5 MRS ESR_EL1, R6 // 065238d5 MSR R21, ESR_EL1 // 155218d5 MRS ESR_EL1, R17 // 115238d5 MSR R12, ESR_EL1 // 0c5218d5 MRS FAR_EL1, R3 // 036038d5 MSR R17, FAR_EL1 // 116018d5 MRS FAR_EL1, R9 // 096038d5 MSR R25, FAR_EL1 // 196018d5 MRS FPCR, R1 // 01443bd5 MSR R27, FPCR // 1b441bd5 MRS FPSR, R5 // 25443bd5 MSR R15, FPSR // 2f441bd5 MRS ID_AA64AFR0_EL1, R19 // 930538d5 MRS ID_AA64AFR1_EL1, R24 // b80538d5 MRS ID_AA64DFR0_EL1, R21 // 150538d5 MRS ID_AA64DFR1_EL1, R20 // 340538d5 MRS ID_AA64ISAR0_EL1, R4 // 040638d5 MRS ID_AA64ISAR1_EL1, R6 // 260638d5 MRS ID_AA64MMFR0_EL1, R0 // 000738d5 MRS ID_AA64MMFR1_EL1, R17 // 310738d5 MRS ID_AA64MMFR2_EL1, R23 // 570738d5 MRS ID_AA64PFR0_EL1, R20 // 140438d5 MRS ID_AA64PFR1_EL1, R26 // 3a0438d5 MRS ID_AA64ZFR0_EL1, R26 // 9a0438d5 MRS ID_AFR0_EL1, R21 // 750138d5 MRS ID_DFR0_EL1, R15 // 4f0138d5 MRS ID_ISAR0_EL1, R11 // 0b0238d5 MRS ID_ISAR1_EL1, R16 // 300238d5 MRS ID_ISAR2_EL1, R10 // 4a0238d5 MRS ID_ISAR3_EL1, R13 // 6d0238d5 MRS ID_ISAR4_EL1, R24 // 980238d5 MRS ID_ISAR5_EL1, R29 // bd0238d5 MRS ID_MMFR0_EL1, R10 // 8a0138d5 MRS ID_MMFR1_EL1, R29 // bd0138d5 MRS ID_MMFR2_EL1, R16 // d00138d5 MRS ID_MMFR3_EL1, R10 // ea0138d5 MRS ID_MMFR4_EL1, R23 // d70238d5 MRS ID_PFR0_EL1, R4 // 040138d5 MRS ID_PFR1_EL1, R12 // 2c0138d5 MRS ISR_EL1, R24 // 18c138d5 MRS MAIR_EL1, R20 // 14a238d5 MSR R21, MAIR_EL1 // 15a218d5 MRS MAIR_EL1, R20 // 14a238d5 MSR R5, MAIR_EL1 // 05a218d5 MRS MDCCINT_EL1, R23 // 170230d5 MSR R27, MDCCINT_EL1 // 1b0210d5 MRS MDCCSR_EL0, R19 // 130133d5 MRS MDRAR_EL1, R12 // 0c1030d5 MRS MDSCR_EL1, R15 // 4f0230d5 MSR R15, MDSCR_EL1 // 4f0210d5 MRS MIDR_EL1, R26 // 1a0038d5 MRS MPIDR_EL1, R25 // b90038d5 MRS MVFR0_EL1, R29 // 1d0338d5 MRS MVFR1_EL1, R7 // 270338d5 MRS MVFR2_EL1, R19 // 530338d5 MRS NZCV, R11 // 0b423bd5 MSR R10, NZCV // 0a421bd5 MRS OSDLR_EL1, R16 // 901330d5 MSR R21, OSDLR_EL1 // 951310d5 MRS OSDTRRX_EL1, R5 // 450030d5 MSR R30, OSDTRRX_EL1 // 5e0010d5 MRS OSDTRTX_EL1, R3 // 430330d5 MSR R13, OSDTRTX_EL1 // 4d0310d5 MRS OSECCR_EL1, R2 // 420630d5 MSR R17, OSECCR_EL1 // 510610d5 MSR R3, OSLAR_EL1 // 831010d5 MRS OSLSR_EL1, R15 // 8f1130d5 MRS PAN, R14 // 6e4238d5 MSR R0, PAN // 604218d5 MRS PAR_EL1, R27 // 1b7438d5 MSR R3, PAR_EL1 // 037418d5 MRS PMCCFILTR_EL0, R10 // eaef3bd5 MSR R16, PMCCFILTR_EL0 // f0ef1bd5 MRS PMCCNTR_EL0, R17 // 119d3bd5 MSR R13, PMCCNTR_EL0 // 0d9d1bd5 MRS PMCEID0_EL0, R8 // c89c3bd5 MRS PMCEID1_EL0, R30 // fe9c3bd5 MRS PMCNTENCLR_EL0, R11 // 4b9c3bd5 MSR R21, PMCNTENCLR_EL0 // 559c1bd5 MRS PMCNTENSET_EL0, R25 // 399c3bd5 MSR R13, PMCNTENSET_EL0 // 2d9c1bd5 MRS PMCR_EL0, R23 // 179c3bd5 MSR R11, PMCR_EL0 // 0b9c1bd5 MRS PMEVCNTR0_EL0, R27 // 1be83bd5 MRS PMEVCNTR1_EL0, R23 // 37e83bd5 MRS PMEVCNTR2_EL0, R26 // 5ae83bd5 MRS PMEVCNTR3_EL0, R11 // 6be83bd5 MRS PMEVCNTR4_EL0, R14 // 8ee83bd5 MRS PMEVCNTR5_EL0, R9 // a9e83bd5 MRS PMEVCNTR6_EL0, R30 // dee83bd5 MRS PMEVCNTR7_EL0, R19 // f3e83bd5 MRS PMEVCNTR8_EL0, R5 // 05e93bd5 MRS PMEVCNTR9_EL0, R27 // 3be93bd5 MRS PMEVCNTR10_EL0, R23 // 57e93bd5 MRS PMEVCNTR11_EL0, R27 // 7be93bd5 MRS PMEVCNTR12_EL0, R0 // 80e93bd5 MRS PMEVCNTR13_EL0, R13 // ade93bd5 MRS PMEVCNTR14_EL0, R27 // dbe93bd5 MRS PMEVCNTR15_EL0, R16 // f0e93bd5 MRS PMEVCNTR16_EL0, R16 // 10ea3bd5 MRS PMEVCNTR17_EL0, R14 // 2eea3bd5 MRS PMEVCNTR18_EL0, R10 // 4aea3bd5 MRS PMEVCNTR19_EL0, R12 // 6cea3bd5 MRS PMEVCNTR20_EL0, R5 // 85ea3bd5 MRS PMEVCNTR21_EL0, R26 // baea3bd5 MRS PMEVCNTR22_EL0, R19 // d3ea3bd5 MRS PMEVCNTR23_EL0, R5 // e5ea3bd5 MRS PMEVCNTR24_EL0, R17 // 11eb3bd5 MRS PMEVCNTR25_EL0, R0 // 20eb3bd5 MRS PMEVCNTR26_EL0, R20 // 54eb3bd5 MRS PMEVCNTR27_EL0, R12 // 6ceb3bd5 MRS PMEVCNTR28_EL0, R29 // 9deb3bd5 MRS PMEVCNTR29_EL0, R22 // b6eb3bd5 MRS PMEVCNTR30_EL0, R22 // d6eb3bd5 MSR R30, PMEVCNTR0_EL0 // 1ee81bd5 MSR R1, PMEVCNTR1_EL0 // 21e81bd5 MSR R20, PMEVCNTR2_EL0 // 54e81bd5 MSR R9, PMEVCNTR3_EL0 // 69e81bd5 MSR R8, PMEVCNTR4_EL0 // 88e81bd5 MSR R2, PMEVCNTR5_EL0 // a2e81bd5 MSR R30, PMEVCNTR6_EL0 // dee81bd5 MSR R14, PMEVCNTR7_EL0 // eee81bd5 MSR R1, PMEVCNTR8_EL0 // 01e91bd5 MSR R15, PMEVCNTR9_EL0 // 2fe91bd5 MSR R15, PMEVCNTR10_EL0 // 4fe91bd5 MSR R14, PMEVCNTR11_EL0 // 6ee91bd5 MSR R15, PMEVCNTR12_EL0 // 8fe91bd5 MSR R25, PMEVCNTR13_EL0 // b9e91bd5 MSR R26, PMEVCNTR14_EL0 // dae91bd5 MSR R21, PMEVCNTR15_EL0 // f5e91bd5 MSR R29, PMEVCNTR16_EL0 // 1dea1bd5 MSR R11, PMEVCNTR17_EL0 // 2bea1bd5 MSR R16, PMEVCNTR18_EL0 // 50ea1bd5 MSR R2, PMEVCNTR19_EL0 // 62ea1bd5 MSR R19, PMEVCNTR20_EL0 // 93ea1bd5 MSR R17, PMEVCNTR21_EL0 // b1ea1bd5 MSR R7, PMEVCNTR22_EL0 // c7ea1bd5 MSR R23, PMEVCNTR23_EL0 // f7ea1bd5 MSR R15, PMEVCNTR24_EL0 // 0feb1bd5 MSR R27, PMEVCNTR25_EL0 // 3beb1bd5 MSR R13, PMEVCNTR26_EL0 // 4deb1bd5 MSR R2, PMEVCNTR27_EL0 // 62eb1bd5 MSR R15, PMEVCNTR28_EL0 // 8feb1bd5 MSR R14, PMEVCNTR29_EL0 // aeeb1bd5 MSR R23, PMEVCNTR30_EL0 // d7eb1bd5 MRS PMEVTYPER0_EL0, R23 // 17ec3bd5 MRS PMEVTYPER1_EL0, R30 // 3eec3bd5 MRS PMEVTYPER2_EL0, R12 // 4cec3bd5 MRS PMEVTYPER3_EL0, R13 // 6dec3bd5 MRS PMEVTYPER4_EL0, R25 // 99ec3bd5 MRS PMEVTYPER5_EL0, R23 // b7ec3bd5 MRS PMEVTYPER6_EL0, R8 // c8ec3bd5 MRS PMEVTYPER7_EL0, R2 // e2ec3bd5 MRS PMEVTYPER8_EL0, R23 // 17ed3bd5 MRS PMEVTYPER9_EL0, R25 // 39ed3bd5 MRS PMEVTYPER10_EL0, R0 // 40ed3bd5 MRS PMEVTYPER11_EL0, R30 // 7eed3bd5 MRS PMEVTYPER12_EL0, R0 // 80ed3bd5 MRS PMEVTYPER13_EL0, R9 // a9ed3bd5 MRS PMEVTYPER14_EL0, R15 // cfed3bd5 MRS PMEVTYPER15_EL0, R13 // eded3bd5 MRS PMEVTYPER16_EL0, R11 // 0bee3bd5 MRS PMEVTYPER17_EL0, R19 // 33ee3bd5 MRS PMEVTYPER18_EL0, R3 // 43ee3bd5 MRS PMEVTYPER19_EL0, R17 // 71ee3bd5 MRS PMEVTYPER20_EL0, R8 // 88ee3bd5 MRS PMEVTYPER21_EL0, R2 // a2ee3bd5 MRS PMEVTYPER22_EL0, R5 // c5ee3bd5 MRS PMEVTYPER23_EL0, R17 // f1ee3bd5 MRS PMEVTYPER24_EL0, R22 // 16ef3bd5 MRS PMEVTYPER25_EL0, R3 // 23ef3bd5 MRS PMEVTYPER26_EL0, R23 // 57ef3bd5 MRS PMEVTYPER27_EL0, R19 // 73ef3bd5 MRS PMEVTYPER28_EL0, R24 // 98ef3bd5 MRS PMEVTYPER29_EL0, R3 // a3ef3bd5 MRS PMEVTYPER30_EL0, R1 // c1ef3bd5 MSR R20, PMEVTYPER0_EL0 // 14ec1bd5 MSR R20, PMEVTYPER1_EL0 // 34ec1bd5 MSR R14, PMEVTYPER2_EL0 // 4eec1bd5 MSR R26, PMEVTYPER3_EL0 // 7aec1bd5 MSR R11, PMEVTYPER4_EL0 // 8bec1bd5 MSR R16, PMEVTYPER5_EL0 // b0ec1bd5 MSR R29, PMEVTYPER6_EL0 // ddec1bd5 MSR R3, PMEVTYPER7_EL0 // e3ec1bd5 MSR R30, PMEVTYPER8_EL0 // 1eed1bd5 MSR R17, PMEVTYPER9_EL0 // 31ed1bd5 MSR R10, PMEVTYPER10_EL0 // 4aed1bd5 MSR R19, PMEVTYPER11_EL0 // 73ed1bd5 MSR R13, PMEVTYPER12_EL0 // 8ded1bd5 MSR R23, PMEVTYPER13_EL0 // b7ed1bd5 MSR R13, PMEVTYPER14_EL0 // cded1bd5 MSR R9, PMEVTYPER15_EL0 // e9ed1bd5 MSR R1, PMEVTYPER16_EL0 // 01ee1bd5 MSR R19, PMEVTYPER17_EL0 // 33ee1bd5 MSR R22, PMEVTYPER18_EL0 // 56ee1bd5 MSR R23, PMEVTYPER19_EL0 // 77ee1bd5 MSR R30, PMEVTYPER20_EL0 // 9eee1bd5 MSR R9, PMEVTYPER21_EL0 // a9ee1bd5 MSR R3, PMEVTYPER22_EL0 // c3ee1bd5 MSR R1, PMEVTYPER23_EL0 // e1ee1bd5 MSR R16, PMEVTYPER24_EL0 // 10ef1bd5 MSR R12, PMEVTYPER25_EL0 // 2cef1bd5 MSR R7, PMEVTYPER26_EL0 // 47ef1bd5 MSR R9, PMEVTYPER27_EL0 // 69ef1bd5 MSR R10, PMEVTYPER28_EL0 // 8aef1bd5 MSR R5, PMEVTYPER29_EL0 // a5ef1bd5 MSR R12, PMEVTYPER30_EL0 // ccef1bd5 MRS PMINTENCLR_EL1, R24 // 589e38d5 MSR R15, PMINTENCLR_EL1 // 4f9e18d5 MRS PMINTENSET_EL1, R1 // 219e38d5 MSR R4, PMINTENSET_EL1 // 249e18d5 MRS PMOVSCLR_EL0, R6 // 669c3bd5 MSR R30, PMOVSCLR_EL0 // 7e9c1bd5 MRS PMOVSSET_EL0, R16 // 709e3bd5 MSR R12, PMOVSSET_EL0 // 6c9e1bd5 MRS PMSELR_EL0, R30 // be9c3bd5 MSR R5, PMSELR_EL0 // a59c1bd5 MSR R27, PMSWINC_EL0 // 9b9c1bd5 MRS PMUSERENR_EL0, R8 // 089e3bd5 MSR R6, PMUSERENR_EL0 // 069e1bd5 MRS PMXEVCNTR_EL0, R26 // 5a9d3bd5 MSR R10, PMXEVCNTR_EL0 // 4a9d1bd5 MRS PMXEVTYPER_EL0, R4 // 249d3bd5 MSR R4, PMXEVTYPER_EL0 // 249d1bd5 MRS REVIDR_EL1, R29 // dd0038d5 MRS RMR_EL1, R4 // 44c038d5 MSR R0, RMR_EL1 // 40c018d5 MRS RVBAR_EL1, R7 // 27c038d5 MRS SCTLR_EL1, R8 // 081038d5 MSR R0, SCTLR_EL1 // 001018d5 MRS SCTLR_EL1, R30 // 1e1038d5 MSR R13, SCTLR_EL1 // 0d1018d5 MRS SPSR_EL1, R1 // 014038d5 MSR R2, SPSR_EL1 // 024018d5 MRS SPSR_EL1, R3 // 034038d5 MSR R14, SPSR_EL1 // 0e4018d5 MRS SPSR_abt, R12 // 2c433cd5 MSR R4, SPSR_abt // 24431cd5 MRS SPSR_fiq, R17 // 71433cd5 MSR R9, SPSR_fiq // 69431cd5 MRS SPSR_irq, R12 // 0c433cd5 MSR R23, SPSR_irq // 17431cd5 MRS SPSR_und, R29 // 5d433cd5 MSR R3, SPSR_und // 43431cd5 MRS SPSel, R29 // 1d4238d5 MSR R1, SPSel // 014218d5 MRS SP_EL0, R10 // 0a4138d5 MSR R4, SP_EL0 // 044118d5 MRS SP_EL1, R22 // 16413cd5 MSR R17, SP_EL1 // 11411cd5 MRS TCR_EL1, R17 // 512038d5 MSR R23, TCR_EL1 // 572018d5 MRS TCR_EL1, R14 // 4e2038d5 MSR R29, TCR_EL1 // 5d2018d5 MRS TPIDRRO_EL0, R26 // 7ad03bd5 MSR R16, TPIDRRO_EL0 // 70d01bd5 MRS TPIDR_EL0, R23 // 57d03bd5 MSR R5, TPIDR_EL0 // 45d01bd5 MRS TPIDR_EL1, R17 // 91d038d5 MSR R22, TPIDR_EL1 // 96d018d5 MRS TTBR0_EL1, R30 // 1e2038d5 MSR R29, TTBR0_EL1 // 1d2018d5 MRS TTBR0_EL1, R23 // 172038d5 MSR R15, TTBR0_EL1 // 0f2018d5 MRS TTBR1_EL1, R5 // 252038d5 MSR R26, TTBR1_EL1 // 3a2018d5 MRS TTBR1_EL1, R19 // 332038d5 MSR R23, TTBR1_EL1 // 372018d5 MRS UAO, R22 // 964238d5 MSR R4, UAO // 844218d5 MRS VBAR_EL1, R23 // 17c038d5 MSR R2, VBAR_EL1 // 02c018d5 MRS VBAR_EL1, R6 // 06c038d5 MSR R3, VBAR_EL1 // 03c018d5 MRS DISR_EL1, R12 // 2cc138d5 MSR R24, DISR_EL1 // 38c118d5 MRS MPIDR_EL1, R1 // a10038d5 MRS MIDR_EL1, R13 // 0d0038d5 MRS ZCR_EL1, R24 // 181238d5 MSR R13, ZCR_EL1 // 0d1218d5 MRS ZCR_EL1, R23 // 171238d5 MSR R17, ZCR_EL1 // 111218d5 SYS $32768, R1 // 018008d5 SYS $32768 // 1f8008d5 MSR $1, DIT // 5f4103d5 // TLBI instruction TLBI VMALLE1IS // 1f8308d5 TLBI VMALLE1 // 1f8708d5 TLBI ALLE2IS // 1f830cd5 TLBI ALLE1IS // 9f830cd5 TLBI VMALLS12E1IS // df830cd5 TLBI ALLE2 // 1f870cd5 TLBI ALLE1 // 9f870cd5 TLBI VMALLS12E1 // df870cd5 TLBI ALLE3IS // 1f830ed5 TLBI ALLE3 // 1f870ed5 TLBI VMALLE1OS // 1f8108d5 TLBI ALLE2OS // 1f810cd5 TLBI ALLE1OS // 9f810cd5 TLBI VMALLS12E1OS // df810cd5 TLBI ALLE3OS // 1f810ed5 TLBI VAE1IS, R0 // 208308d5 TLBI ASIDE1IS, R1 // 418308d5 TLBI VAAE1IS, R2 // 628308d5 TLBI VALE1IS, R3 // a38308d5 TLBI VAALE1IS, R4 // e48308d5 TLBI VAE1, R5 // 258708d5 TLBI ASIDE1, R6 // 468708d5 TLBI VAAE1, R7 // 678708d5 TLBI VALE1, R8 // a88708d5 TLBI VAALE1, R9 // e98708d5 TLBI IPAS2E1IS, R10 // 2a800cd5 TLBI IPAS2LE1IS, R11 // ab800cd5 TLBI VAE2IS, R12 // 2c830cd5 TLBI VALE2IS, R13 // ad830cd5 TLBI IPAS2E1, R14 // 2e840cd5 TLBI IPAS2LE1, R15 // af840cd5 TLBI VAE2, R16 // 30870cd5 TLBI VALE2, R17 // b1870cd5 TLBI VAE3IS, ZR // 3f830ed5 TLBI VALE3IS, R19 // b3830ed5 TLBI VAE3, R20 // 34870ed5 TLBI VALE3, R21 // b5870ed5 TLBI VAE1OS, R22 // 368108d5 TLBI ASIDE1OS, R23 // 578108d5 TLBI VAAE1OS, R24 // 788108d5 TLBI VALE1OS, R25 // b98108d5 TLBI VAALE1OS, R26 // fa8108d5 TLBI RVAE1IS, R27 // 3b8208d5 TLBI RVAAE1IS, ZR // 7f8208d5 TLBI RVALE1IS, R29 // bd8208d5 TLBI RVAALE1IS, R30 // fe8208d5 TLBI RVAE1OS, ZR // 3f8508d5 TLBI RVAAE1OS, R0 // 608508d5 TLBI RVALE1OS, R1 // a18508d5 TLBI RVAALE1OS, R2 // e28508d5 TLBI RVAE1, R3 // 238608d5 TLBI RVAAE1, R4 // 648608d5 TLBI RVALE1, R5 // a58608d5 TLBI RVAALE1, R6 // e68608d5 TLBI RIPAS2E1IS, R7 // 47800cd5 TLBI RIPAS2LE1IS, R8 // c8800cd5 TLBI VAE2OS, R9 // 29810cd5 TLBI VALE2OS, R10 // aa810cd5 TLBI RVAE2IS, R11 // 2b820cd5 TLBI RVALE2IS, R12 // ac820cd5 TLBI IPAS2E1OS, R13 // 0d840cd5 TLBI RIPAS2E1, R14 // 4e840cd5 TLBI RIPAS2E1OS, R15 // 6f840cd5 TLBI IPAS2LE1OS, R16 // 90840cd5 TLBI RIPAS2LE1, R17 // d1840cd5 TLBI RIPAS2LE1OS, ZR // ff840cd5 TLBI RVAE2OS, R19 // 33850cd5 TLBI RVALE2OS, R20 // b4850cd5 TLBI RVAE2, R21 // 35860cd5 TLBI RVALE2, R22 // b6860cd5 TLBI VAE3OS, R23 // 37810ed5 TLBI VALE3OS, R24 // b8810ed5 TLBI RVAE3IS, R25 // 39820ed5 TLBI RVALE3IS, R26 // ba820ed5 TLBI RVAE3OS, R27 // 3b850ed5 TLBI RVALE3OS, ZR // bf850ed5 TLBI RVAE3, R29 // 3d860ed5 TLBI RVALE3, R30 // be860ed5 // DC instruction DC IVAC, R0 // 207608d5 DC ISW, R1 // 417608d5 DC CSW, R2 // 427a08d5 DC CISW, R3 // 437e08d5 DC ZVA, R4 // 24740bd5 DC CVAC, R5 // 257a0bd5 DC CVAU, R6 // 267b0bd5 DC CIVAC, R7 // 277e0bd5 DC IGVAC, R8 // 687608d5 DC IGSW, R9 // 897608d5 DC IGDVAC, R10 // aa7608d5 DC IGDSW, R11 // cb7608d5 DC CGSW, R12 // 8c7a08d5 DC CGDSW, R13 // cd7a08d5 DC CIGSW, R14 // 8e7e08d5 DC CIGDSW, R15 // cf7e08d5 DC GVA, R16 // 70740bd5 DC GZVA, R17 // 91740bd5 DC CGVAC, ZR // 7f7a0bd5 DC CGDVAC, R19 // b37a0bd5 DC CGVAP, R20 // 747c0bd5 DC CGDVAP, R21 // b57c0bd5 DC CGVADP, R22 // 767d0bd5 DC CGDVADP, R23 // b77d0bd5 DC CIGVAC, R24 // 787e0bd5 DC CIGDVAC, R25 // b97e0bd5 DC CVAP, R26 // 3a7c0bd5 DC CVADP, R27 // 3b7d0bd5 END
go/src/cmd/asm/internal/asm/testdata/arm64.s/0
{ "file_path": "go/src/cmd/asm/internal/asm/testdata/arm64.s", "repo_id": "go", "token_count": 72519 }
65
// Code generated by avx512test. DO NOT EDIT. #include "../../../../../../runtime/textflag.h" TEXT asmtest_avx512dq(SB), NOSPLIT, $0 KADDB K3, K1, K6 // c5f54af3 KADDB K1, K1, K6 // c5f54af1 KADDB K3, K5, K6 // c5d54af3 KADDB K1, K5, K6 // c5d54af1 KADDB K3, K1, K5 // c5f54aeb KADDB K1, K1, K5 // c5f54ae9 KADDB K3, K5, K5 // c5d54aeb KADDB K1, K5, K5 // c5d54ae9 KADDW K6, K6, K1 // c5cc4ace KADDW K4, K6, K1 // c5cc4acc KADDW K6, K7, K1 // c5c44ace KADDW K4, K7, K1 // c5c44acc KADDW K6, K6, K3 // c5cc4ade KADDW K4, K6, K3 // c5cc4adc KADDW K6, K7, K3 // c5c44ade KADDW K4, K7, K3 // c5c44adc KANDB K2, K4, K4 // c5dd41e2 KANDB K7, K4, K4 // c5dd41e7 KANDB K2, K5, K4 // c5d541e2 KANDB K7, K5, K4 // c5d541e7 KANDB K2, K4, K6 // c5dd41f2 KANDB K7, K4, K6 // c5dd41f7 KANDB K2, K5, K6 // c5d541f2 KANDB K7, K5, K6 // c5d541f7 KANDNB K7, K5, K3 // c5d542df KANDNB K6, K5, K3 // c5d542de KANDNB K7, K4, K3 // c5dd42df KANDNB K6, K4, K3 // c5dd42de KANDNB K7, K5, K1 // c5d542cf KANDNB K6, K5, K1 // c5d542ce KANDNB K7, K4, K1 // c5dd42cf KANDNB K6, K4, K1 // c5dd42ce KMOVB K7, 17(SP) // c5f9917c2411 KMOVB K6, 17(SP) // c5f991742411 KMOVB K7, -17(BP)(SI*4) // c5f9917cb5ef KMOVB K6, -17(BP)(SI*4) // c5f99174b5ef KMOVB K4, AX // c5f993c4 KMOVB K6, AX // c5f993c6 KMOVB K4, R9 // c57993cc KMOVB K6, R9 // c57993ce KMOVB K5, K0 // c5f990c5 KMOVB K4, K0 // c5f990c4 KMOVB 7(AX), K0 // c5f9904007 KMOVB (DI), K0 // c5f99007 KMOVB K5, K7 // c5f990fd KMOVB K4, K7 // c5f990fc KMOVB 7(AX), K7 // c5f9907807 KMOVB (DI), K7 // c5f9903f KMOVB CX, K4 // c5f992e1 KMOVB SP, K4 // c5f992e4 KMOVB CX, K6 // c5f992f1 KMOVB SP, K6 // c5f992f4 KNOTB K1, K4 // c5f944e1 KNOTB K3, K4 // c5f944e3 KNOTB K1, K6 // c5f944f1 KNOTB K3, K6 // c5f944f3 KORB K3, K1, K6 // c5f545f3 KORB K1, K1, K6 // c5f545f1 KORB K3, K5, K6 // c5d545f3 KORB K1, K5, K6 // c5d545f1 KORB K3, K1, K5 // c5f545eb KORB K1, K1, K5 // c5f545e9 KORB K3, K5, K5 // c5d545eb KORB K1, K5, K5 // c5d545e9 KORTESTB K6, K1 // c5f998ce KORTESTB K7, K1 // c5f998cf KORTESTB K6, K3 // c5f998de KORTESTB K7, K3 // c5f998df KSHIFTLB $127, K4, K7 // c4e37932fc7f KSHIFTLB $127, K6, K7 // c4e37932fe7f KSHIFTLB $127, K4, K6 // c4e37932f47f KSHIFTLB $127, K6, K6 // c4e37932f67f KSHIFTRB $42, K4, K4 // c4e37930e42a KSHIFTRB $42, K5, K4 // c4e37930e52a KSHIFTRB $42, K4, K6 // c4e37930f42a KSHIFTRB $42, K5, K6 // c4e37930f52a KTESTB K4, K7 // c5f999fc KTESTB K6, K7 // c5f999fe KTESTB K4, K6 // c5f999f4 KTESTB K6, K6 // c5f999f6 KTESTW K6, K6 // c5f899f6 KTESTW K4, K6 // c5f899f4 KTESTW K6, K7 // c5f899fe KTESTW K4, K7 // c5f899fc KXNORB K5, K0, K4 // c5fd46e5 KXNORB K4, K0, K4 // c5fd46e4 KXNORB K5, K7, K4 // c5c546e5 KXNORB K4, K7, K4 // c5c546e4 KXNORB K5, K0, K6 // c5fd46f5 KXNORB K4, K0, K6 // c5fd46f4 KXNORB K5, K7, K6 // c5c546f5 KXNORB K4, K7, K6 // c5c546f4 KXORB K5, K3, K1 // c5e547cd KXORB K4, K3, K1 // c5e547cc KXORB K5, K1, K1 // c5f547cd KXORB K4, K1, K1 // c5f547cc KXORB K5, K3, K5 // c5e547ed KXORB K4, K3, K5 // c5e547ec KXORB K5, K1, K5 // c5f547ed KXORB K4, K1, K5 // c5f547ec VANDNPD X15, X0, K4, X22 // 62c1fd0c55f7 VANDNPD X11, X0, K4, X22 // 62c1fd0c55f3 VANDNPD X0, X0, K4, X22 // 62e1fd0c55f0 VANDNPD (R8), X0, K4, X22 // 62c1fd0c5530 VANDNPD 15(DX)(BX*2), X0, K4, X22 // 62e1fd0c55b45a0f000000 VANDNPD X15, X17, K4, X22 // 62c1f50455f7 VANDNPD X11, X17, K4, X22 // 62c1f50455f3 VANDNPD X0, X17, K4, X22 // 62e1f50455f0 VANDNPD (R8), X17, K4, X22 // 62c1f5045530 VANDNPD 15(DX)(BX*2), X17, K4, X22 // 62e1f50455b45a0f000000 VANDNPD X15, X7, K4, X22 // 62c1c50c55f7 VANDNPD X11, X7, K4, X22 // 62c1c50c55f3 VANDNPD X0, X7, K4, X22 // 62e1c50c55f0 VANDNPD (R8), X7, K4, X22 // 62c1c50c5530 VANDNPD 15(DX)(BX*2), X7, K4, X22 // 62e1c50c55b45a0f000000 VANDNPD X15, X0, K4, X5 // 62d1fd0c55ef VANDNPD X11, X0, K4, X5 // 62d1fd0c55eb VANDNPD X0, X0, K4, X5 // 62f1fd0c55e8 VANDNPD (R8), X0, K4, X5 // 62d1fd0c5528 VANDNPD 15(DX)(BX*2), X0, K4, X5 // 62f1fd0c55ac5a0f000000 VANDNPD X15, X17, K4, X5 // 62d1f50455ef VANDNPD X11, X17, K4, X5 // 62d1f50455eb VANDNPD X0, X17, K4, X5 // 62f1f50455e8 VANDNPD (R8), X17, K4, X5 // 62d1f5045528 VANDNPD 15(DX)(BX*2), X17, K4, X5 // 62f1f50455ac5a0f000000 VANDNPD X15, X7, K4, X5 // 62d1c50c55ef VANDNPD X11, X7, K4, X5 // 62d1c50c55eb VANDNPD X0, X7, K4, X5 // 62f1c50c55e8 VANDNPD (R8), X7, K4, X5 // 62d1c50c5528 VANDNPD 15(DX)(BX*2), X7, K4, X5 // 62f1c50c55ac5a0f000000 VANDNPD X15, X0, K4, X14 // 6251fd0c55f7 VANDNPD X11, X0, K4, X14 // 6251fd0c55f3 VANDNPD X0, X0, K4, X14 // 6271fd0c55f0 VANDNPD (R8), X0, K4, X14 // 6251fd0c5530 VANDNPD 15(DX)(BX*2), X0, K4, X14 // 6271fd0c55b45a0f000000 VANDNPD X15, X17, K4, X14 // 6251f50455f7 VANDNPD X11, X17, K4, X14 // 6251f50455f3 VANDNPD X0, X17, K4, X14 // 6271f50455f0 VANDNPD (R8), X17, K4, X14 // 6251f5045530 VANDNPD 15(DX)(BX*2), X17, K4, X14 // 6271f50455b45a0f000000 VANDNPD X15, X7, K4, X14 // 6251c50c55f7 VANDNPD X11, X7, K4, X14 // 6251c50c55f3 VANDNPD X0, X7, K4, X14 // 6271c50c55f0 VANDNPD (R8), X7, K4, X14 // 6251c50c5530 VANDNPD 15(DX)(BX*2), X7, K4, X14 // 6271c50c55b45a0f000000 VANDNPD Y17, Y12, K5, Y0 // 62b19d2d55c1 VANDNPD Y7, Y12, K5, Y0 // 62f19d2d55c7 VANDNPD Y9, Y12, K5, Y0 // 62d19d2d55c1 VANDNPD 99(R15)(R15*8), Y12, K5, Y0 // 62919d2d5584ff63000000 VANDNPD 7(AX)(CX*8), Y12, K5, Y0 // 62f19d2d5584c807000000 VANDNPD Y17, Y1, K5, Y0 // 62b1f52d55c1 VANDNPD Y7, Y1, K5, Y0 // 62f1f52d55c7 VANDNPD Y9, Y1, K5, Y0 // 62d1f52d55c1 VANDNPD 99(R15)(R15*8), Y1, K5, Y0 // 6291f52d5584ff63000000 VANDNPD 7(AX)(CX*8), Y1, K5, Y0 // 62f1f52d5584c807000000 VANDNPD Y17, Y14, K5, Y0 // 62b18d2d55c1 VANDNPD Y7, Y14, K5, Y0 // 62f18d2d55c7 VANDNPD Y9, Y14, K5, Y0 // 62d18d2d55c1 VANDNPD 99(R15)(R15*8), Y14, K5, Y0 // 62918d2d5584ff63000000 VANDNPD 7(AX)(CX*8), Y14, K5, Y0 // 62f18d2d5584c807000000 VANDNPD Y17, Y12, K5, Y22 // 62a19d2d55f1 VANDNPD Y7, Y12, K5, Y22 // 62e19d2d55f7 VANDNPD Y9, Y12, K5, Y22 // 62c19d2d55f1 VANDNPD 99(R15)(R15*8), Y12, K5, Y22 // 62819d2d55b4ff63000000 VANDNPD 7(AX)(CX*8), Y12, K5, Y22 // 62e19d2d55b4c807000000 VANDNPD Y17, Y1, K5, Y22 // 62a1f52d55f1 VANDNPD Y7, Y1, K5, Y22 // 62e1f52d55f7 VANDNPD Y9, Y1, K5, Y22 // 62c1f52d55f1 VANDNPD 99(R15)(R15*8), Y1, K5, Y22 // 6281f52d55b4ff63000000 VANDNPD 7(AX)(CX*8), Y1, K5, Y22 // 62e1f52d55b4c807000000 VANDNPD Y17, Y14, K5, Y22 // 62a18d2d55f1 VANDNPD Y7, Y14, K5, Y22 // 62e18d2d55f7 VANDNPD Y9, Y14, K5, Y22 // 62c18d2d55f1 VANDNPD 99(R15)(R15*8), Y14, K5, Y22 // 62818d2d55b4ff63000000 VANDNPD 7(AX)(CX*8), Y14, K5, Y22 // 62e18d2d55b4c807000000 VANDNPD Y17, Y12, K5, Y13 // 62319d2d55e9 VANDNPD Y7, Y12, K5, Y13 // 62719d2d55ef VANDNPD Y9, Y12, K5, Y13 // 62519d2d55e9 VANDNPD 99(R15)(R15*8), Y12, K5, Y13 // 62119d2d55acff63000000 VANDNPD 7(AX)(CX*8), Y12, K5, Y13 // 62719d2d55acc807000000 VANDNPD Y17, Y1, K5, Y13 // 6231f52d55e9 VANDNPD Y7, Y1, K5, Y13 // 6271f52d55ef VANDNPD Y9, Y1, K5, Y13 // 6251f52d55e9 VANDNPD 99(R15)(R15*8), Y1, K5, Y13 // 6211f52d55acff63000000 VANDNPD 7(AX)(CX*8), Y1, K5, Y13 // 6271f52d55acc807000000 VANDNPD Y17, Y14, K5, Y13 // 62318d2d55e9 VANDNPD Y7, Y14, K5, Y13 // 62718d2d55ef VANDNPD Y9, Y14, K5, Y13 // 62518d2d55e9 VANDNPD 99(R15)(R15*8), Y14, K5, Y13 // 62118d2d55acff63000000 VANDNPD 7(AX)(CX*8), Y14, K5, Y13 // 62718d2d55acc807000000 VANDNPD Z20, Z0, K7, Z7 // 62b1fd4f55fc VANDNPD Z28, Z0, K7, Z7 // 6291fd4f55fc VANDNPD 99(R15)(R15*8), Z0, K7, Z7 // 6291fd4f55bcff63000000 VANDNPD 7(AX)(CX*8), Z0, K7, Z7 // 62f1fd4f55bcc807000000 VANDNPD Z20, Z6, K7, Z7 // 62b1cd4f55fc VANDNPD Z28, Z6, K7, Z7 // 6291cd4f55fc VANDNPD 99(R15)(R15*8), Z6, K7, Z7 // 6291cd4f55bcff63000000 VANDNPD 7(AX)(CX*8), Z6, K7, Z7 // 62f1cd4f55bcc807000000 VANDNPD Z20, Z0, K7, Z9 // 6231fd4f55cc VANDNPD Z28, Z0, K7, Z9 // 6211fd4f55cc VANDNPD 99(R15)(R15*8), Z0, K7, Z9 // 6211fd4f558cff63000000 VANDNPD 7(AX)(CX*8), Z0, K7, Z9 // 6271fd4f558cc807000000 VANDNPD Z20, Z6, K7, Z9 // 6231cd4f55cc VANDNPD Z28, Z6, K7, Z9 // 6211cd4f55cc VANDNPD 99(R15)(R15*8), Z6, K7, Z9 // 6211cd4f558cff63000000 VANDNPD 7(AX)(CX*8), Z6, K7, Z9 // 6271cd4f558cc807000000 VANDNPS X15, X25, K7, X18 // 62c1340755d7 VANDNPS X28, X25, K7, X18 // 6281340755d4 VANDNPS 17(SP)(BP*1), X25, K7, X18 // 62e1340755942c11000000 VANDNPS -7(CX)(DX*8), X25, K7, X18 // 62e134075594d1f9ffffff VANDNPS X15, X3, K7, X18 // 62c1640f55d7 VANDNPS X28, X3, K7, X18 // 6281640f55d4 VANDNPS 17(SP)(BP*1), X3, K7, X18 // 62e1640f55942c11000000 VANDNPS -7(CX)(DX*8), X3, K7, X18 // 62e1640f5594d1f9ffffff VANDNPS X15, X18, K7, X18 // 62c16c0755d7 VANDNPS X28, X18, K7, X18 // 62816c0755d4 VANDNPS 17(SP)(BP*1), X18, K7, X18 // 62e16c0755942c11000000 VANDNPS -7(CX)(DX*8), X18, K7, X18 // 62e16c075594d1f9ffffff VANDNPS X15, X25, K7, X8 // 6251340755c7 VANDNPS X28, X25, K7, X8 // 6211340755c4 VANDNPS 17(SP)(BP*1), X25, K7, X8 // 6271340755842c11000000 VANDNPS -7(CX)(DX*8), X25, K7, X8 // 627134075584d1f9ffffff VANDNPS X15, X3, K7, X8 // 6251640f55c7 VANDNPS X28, X3, K7, X8 // 6211640f55c4 VANDNPS 17(SP)(BP*1), X3, K7, X8 // 6271640f55842c11000000 VANDNPS -7(CX)(DX*8), X3, K7, X8 // 6271640f5584d1f9ffffff VANDNPS X15, X18, K7, X8 // 62516c0755c7 VANDNPS X28, X18, K7, X8 // 62116c0755c4 VANDNPS 17(SP)(BP*1), X18, K7, X8 // 62716c0755842c11000000 VANDNPS -7(CX)(DX*8), X18, K7, X8 // 62716c075584d1f9ffffff VANDNPS X15, X25, K7, X27 // 6241340755df VANDNPS X28, X25, K7, X27 // 6201340755dc VANDNPS 17(SP)(BP*1), X25, K7, X27 // 62613407559c2c11000000 VANDNPS -7(CX)(DX*8), X25, K7, X27 // 62613407559cd1f9ffffff VANDNPS X15, X3, K7, X27 // 6241640f55df VANDNPS X28, X3, K7, X27 // 6201640f55dc VANDNPS 17(SP)(BP*1), X3, K7, X27 // 6261640f559c2c11000000 VANDNPS -7(CX)(DX*8), X3, K7, X27 // 6261640f559cd1f9ffffff VANDNPS X15, X18, K7, X27 // 62416c0755df VANDNPS X28, X18, K7, X27 // 62016c0755dc VANDNPS 17(SP)(BP*1), X18, K7, X27 // 62616c07559c2c11000000 VANDNPS -7(CX)(DX*8), X18, K7, X27 // 62616c07559cd1f9ffffff VANDNPS Y2, Y28, K6, Y31 // 62611c2655fa VANDNPS Y21, Y28, K6, Y31 // 62211c2655fd VANDNPS Y12, Y28, K6, Y31 // 62411c2655fc VANDNPS (AX), Y28, K6, Y31 // 62611c265538 VANDNPS 7(SI), Y28, K6, Y31 // 62611c2655be07000000 VANDNPS Y2, Y13, K6, Y31 // 6261142e55fa VANDNPS Y21, Y13, K6, Y31 // 6221142e55fd VANDNPS Y12, Y13, K6, Y31 // 6241142e55fc VANDNPS (AX), Y13, K6, Y31 // 6261142e5538 VANDNPS 7(SI), Y13, K6, Y31 // 6261142e55be07000000 VANDNPS Y2, Y7, K6, Y31 // 6261442e55fa VANDNPS Y21, Y7, K6, Y31 // 6221442e55fd VANDNPS Y12, Y7, K6, Y31 // 6241442e55fc VANDNPS (AX), Y7, K6, Y31 // 6261442e5538 VANDNPS 7(SI), Y7, K6, Y31 // 6261442e55be07000000 VANDNPS Y2, Y28, K6, Y8 // 62711c2655c2 VANDNPS Y21, Y28, K6, Y8 // 62311c2655c5 VANDNPS Y12, Y28, K6, Y8 // 62511c2655c4 VANDNPS (AX), Y28, K6, Y8 // 62711c265500 VANDNPS 7(SI), Y28, K6, Y8 // 62711c26558607000000 VANDNPS Y2, Y13, K6, Y8 // 6271142e55c2 VANDNPS Y21, Y13, K6, Y8 // 6231142e55c5 VANDNPS Y12, Y13, K6, Y8 // 6251142e55c4 VANDNPS (AX), Y13, K6, Y8 // 6271142e5500 VANDNPS 7(SI), Y13, K6, Y8 // 6271142e558607000000 VANDNPS Y2, Y7, K6, Y8 // 6271442e55c2 VANDNPS Y21, Y7, K6, Y8 // 6231442e55c5 VANDNPS Y12, Y7, K6, Y8 // 6251442e55c4 VANDNPS (AX), Y7, K6, Y8 // 6271442e5500 VANDNPS 7(SI), Y7, K6, Y8 // 6271442e558607000000 VANDNPS Y2, Y28, K6, Y1 // 62f11c2655ca VANDNPS Y21, Y28, K6, Y1 // 62b11c2655cd VANDNPS Y12, Y28, K6, Y1 // 62d11c2655cc VANDNPS (AX), Y28, K6, Y1 // 62f11c265508 VANDNPS 7(SI), Y28, K6, Y1 // 62f11c26558e07000000 VANDNPS Y2, Y13, K6, Y1 // 62f1142e55ca VANDNPS Y21, Y13, K6, Y1 // 62b1142e55cd VANDNPS Y12, Y13, K6, Y1 // 62d1142e55cc VANDNPS (AX), Y13, K6, Y1 // 62f1142e5508 VANDNPS 7(SI), Y13, K6, Y1 // 62f1142e558e07000000 VANDNPS Y2, Y7, K6, Y1 // 62f1442e55ca VANDNPS Y21, Y7, K6, Y1 // 62b1442e55cd VANDNPS Y12, Y7, K6, Y1 // 62d1442e55cc VANDNPS (AX), Y7, K6, Y1 // 62f1442e5508 VANDNPS 7(SI), Y7, K6, Y1 // 62f1442e558e07000000 VANDNPS Z12, Z9, K3, Z3 // 62d1344b55dc VANDNPS Z22, Z9, K3, Z3 // 62b1344b55de VANDNPS (AX), Z9, K3, Z3 // 62f1344b5518 VANDNPS 7(SI), Z9, K3, Z3 // 62f1344b559e07000000 VANDNPS Z12, Z19, K3, Z3 // 62d1644355dc VANDNPS Z22, Z19, K3, Z3 // 62b1644355de VANDNPS (AX), Z19, K3, Z3 // 62f164435518 VANDNPS 7(SI), Z19, K3, Z3 // 62f16443559e07000000 VANDNPS Z12, Z9, K3, Z30 // 6241344b55f4 VANDNPS Z22, Z9, K3, Z30 // 6221344b55f6 VANDNPS (AX), Z9, K3, Z30 // 6261344b5530 VANDNPS 7(SI), Z9, K3, Z30 // 6261344b55b607000000 VANDNPS Z12, Z19, K3, Z30 // 6241644355f4 VANDNPS Z22, Z19, K3, Z30 // 6221644355f6 VANDNPS (AX), Z19, K3, Z30 // 626164435530 VANDNPS 7(SI), Z19, K3, Z30 // 6261644355b607000000 VANDPD X22, X24, K7, X7 // 62b1bd0754fe VANDPD X1, X24, K7, X7 // 62f1bd0754f9 VANDPD X11, X24, K7, X7 // 62d1bd0754fb VANDPD -17(BP)(SI*2), X24, K7, X7 // 62f1bd0754bc75efffffff VANDPD 7(AX)(CX*2), X24, K7, X7 // 62f1bd0754bc4807000000 VANDPD X22, X7, K7, X7 // 62b1c50f54fe VANDPD X1, X7, K7, X7 // 62f1c50f54f9 VANDPD X11, X7, K7, X7 // 62d1c50f54fb VANDPD -17(BP)(SI*2), X7, K7, X7 // 62f1c50f54bc75efffffff VANDPD 7(AX)(CX*2), X7, K7, X7 // 62f1c50f54bc4807000000 VANDPD X22, X0, K7, X7 // 62b1fd0f54fe VANDPD X1, X0, K7, X7 // 62f1fd0f54f9 VANDPD X11, X0, K7, X7 // 62d1fd0f54fb VANDPD -17(BP)(SI*2), X0, K7, X7 // 62f1fd0f54bc75efffffff VANDPD 7(AX)(CX*2), X0, K7, X7 // 62f1fd0f54bc4807000000 VANDPD X22, X24, K7, X13 // 6231bd0754ee VANDPD X1, X24, K7, X13 // 6271bd0754e9 VANDPD X11, X24, K7, X13 // 6251bd0754eb VANDPD -17(BP)(SI*2), X24, K7, X13 // 6271bd0754ac75efffffff VANDPD 7(AX)(CX*2), X24, K7, X13 // 6271bd0754ac4807000000 VANDPD X22, X7, K7, X13 // 6231c50f54ee VANDPD X1, X7, K7, X13 // 6271c50f54e9 VANDPD X11, X7, K7, X13 // 6251c50f54eb VANDPD -17(BP)(SI*2), X7, K7, X13 // 6271c50f54ac75efffffff VANDPD 7(AX)(CX*2), X7, K7, X13 // 6271c50f54ac4807000000 VANDPD X22, X0, K7, X13 // 6231fd0f54ee VANDPD X1, X0, K7, X13 // 6271fd0f54e9 VANDPD X11, X0, K7, X13 // 6251fd0f54eb VANDPD -17(BP)(SI*2), X0, K7, X13 // 6271fd0f54ac75efffffff VANDPD 7(AX)(CX*2), X0, K7, X13 // 6271fd0f54ac4807000000 VANDPD X22, X24, K7, X8 // 6231bd0754c6 VANDPD X1, X24, K7, X8 // 6271bd0754c1 VANDPD X11, X24, K7, X8 // 6251bd0754c3 VANDPD -17(BP)(SI*2), X24, K7, X8 // 6271bd07548475efffffff VANDPD 7(AX)(CX*2), X24, K7, X8 // 6271bd0754844807000000 VANDPD X22, X7, K7, X8 // 6231c50f54c6 VANDPD X1, X7, K7, X8 // 6271c50f54c1 VANDPD X11, X7, K7, X8 // 6251c50f54c3 VANDPD -17(BP)(SI*2), X7, K7, X8 // 6271c50f548475efffffff VANDPD 7(AX)(CX*2), X7, K7, X8 // 6271c50f54844807000000 VANDPD X22, X0, K7, X8 // 6231fd0f54c6 VANDPD X1, X0, K7, X8 // 6271fd0f54c1 VANDPD X11, X0, K7, X8 // 6251fd0f54c3 VANDPD -17(BP)(SI*2), X0, K7, X8 // 6271fd0f548475efffffff VANDPD 7(AX)(CX*2), X0, K7, X8 // 6271fd0f54844807000000 VANDPD Y12, Y3, K4, Y9 // 6251e52c54cc VANDPD Y21, Y3, K4, Y9 // 6231e52c54cd VANDPD Y14, Y3, K4, Y9 // 6251e52c54ce VANDPD (BX), Y3, K4, Y9 // 6271e52c540b VANDPD -17(BP)(SI*1), Y3, K4, Y9 // 6271e52c548c35efffffff VANDPD Y12, Y2, K4, Y9 // 6251ed2c54cc VANDPD Y21, Y2, K4, Y9 // 6231ed2c54cd VANDPD Y14, Y2, K4, Y9 // 6251ed2c54ce VANDPD (BX), Y2, K4, Y9 // 6271ed2c540b VANDPD -17(BP)(SI*1), Y2, K4, Y9 // 6271ed2c548c35efffffff VANDPD Y12, Y9, K4, Y9 // 6251b52c54cc VANDPD Y21, Y9, K4, Y9 // 6231b52c54cd VANDPD Y14, Y9, K4, Y9 // 6251b52c54ce VANDPD (BX), Y9, K4, Y9 // 6271b52c540b VANDPD -17(BP)(SI*1), Y9, K4, Y9 // 6271b52c548c35efffffff VANDPD Y12, Y3, K4, Y1 // 62d1e52c54cc VANDPD Y21, Y3, K4, Y1 // 62b1e52c54cd VANDPD Y14, Y3, K4, Y1 // 62d1e52c54ce VANDPD (BX), Y3, K4, Y1 // 62f1e52c540b VANDPD -17(BP)(SI*1), Y3, K4, Y1 // 62f1e52c548c35efffffff VANDPD Y12, Y2, K4, Y1 // 62d1ed2c54cc VANDPD Y21, Y2, K4, Y1 // 62b1ed2c54cd VANDPD Y14, Y2, K4, Y1 // 62d1ed2c54ce VANDPD (BX), Y2, K4, Y1 // 62f1ed2c540b VANDPD -17(BP)(SI*1), Y2, K4, Y1 // 62f1ed2c548c35efffffff VANDPD Y12, Y9, K4, Y1 // 62d1b52c54cc VANDPD Y21, Y9, K4, Y1 // 62b1b52c54cd VANDPD Y14, Y9, K4, Y1 // 62d1b52c54ce VANDPD (BX), Y9, K4, Y1 // 62f1b52c540b VANDPD -17(BP)(SI*1), Y9, K4, Y1 // 62f1b52c548c35efffffff VANDPD Z2, Z18, K4, Z11 // 6271ed4454da VANDPD Z21, Z18, K4, Z11 // 6231ed4454dd VANDPD (BX), Z18, K4, Z11 // 6271ed44541b VANDPD -17(BP)(SI*1), Z18, K4, Z11 // 6271ed44549c35efffffff VANDPD Z2, Z24, K4, Z11 // 6271bd4454da VANDPD Z21, Z24, K4, Z11 // 6231bd4454dd VANDPD (BX), Z24, K4, Z11 // 6271bd44541b VANDPD -17(BP)(SI*1), Z24, K4, Z11 // 6271bd44549c35efffffff VANDPD Z2, Z18, K4, Z5 // 62f1ed4454ea VANDPD Z21, Z18, K4, Z5 // 62b1ed4454ed VANDPD (BX), Z18, K4, Z5 // 62f1ed44542b VANDPD -17(BP)(SI*1), Z18, K4, Z5 // 62f1ed4454ac35efffffff VANDPD Z2, Z24, K4, Z5 // 62f1bd4454ea VANDPD Z21, Z24, K4, Z5 // 62b1bd4454ed VANDPD (BX), Z24, K4, Z5 // 62f1bd44542b VANDPD -17(BP)(SI*1), Z24, K4, Z5 // 62f1bd4454ac35efffffff VANDPS X20, X31, K7, X6 // 62b1040754f4 VANDPS X24, X31, K7, X6 // 6291040754f0 VANDPS X7, X31, K7, X6 // 62f1040754f7 VANDPS 15(R8)(R14*1), X31, K7, X6 // 6291040754b4300f000000 VANDPS 15(R8)(R14*2), X31, K7, X6 // 6291040754b4700f000000 VANDPS X20, X3, K7, X6 // 62b1640f54f4 VANDPS X24, X3, K7, X6 // 6291640f54f0 VANDPS X7, X3, K7, X6 // 62f1640f54f7 VANDPS 15(R8)(R14*1), X3, K7, X6 // 6291640f54b4300f000000 VANDPS 15(R8)(R14*2), X3, K7, X6 // 6291640f54b4700f000000 VANDPS X20, X28, K7, X6 // 62b11c0754f4 VANDPS X24, X28, K7, X6 // 62911c0754f0 VANDPS X7, X28, K7, X6 // 62f11c0754f7 VANDPS 15(R8)(R14*1), X28, K7, X6 // 62911c0754b4300f000000 VANDPS 15(R8)(R14*2), X28, K7, X6 // 62911c0754b4700f000000 VANDPS X20, X31, K7, X7 // 62b1040754fc VANDPS X24, X31, K7, X7 // 6291040754f8 VANDPS X7, X31, K7, X7 // 62f1040754ff VANDPS 15(R8)(R14*1), X31, K7, X7 // 6291040754bc300f000000 VANDPS 15(R8)(R14*2), X31, K7, X7 // 6291040754bc700f000000 VANDPS X20, X3, K7, X7 // 62b1640f54fc VANDPS X24, X3, K7, X7 // 6291640f54f8 VANDPS X7, X3, K7, X7 // 62f1640f54ff VANDPS 15(R8)(R14*1), X3, K7, X7 // 6291640f54bc300f000000 VANDPS 15(R8)(R14*2), X3, K7, X7 // 6291640f54bc700f000000 VANDPS X20, X28, K7, X7 // 62b11c0754fc VANDPS X24, X28, K7, X7 // 62911c0754f8 VANDPS X7, X28, K7, X7 // 62f11c0754ff VANDPS 15(R8)(R14*1), X28, K7, X7 // 62911c0754bc300f000000 VANDPS 15(R8)(R14*2), X28, K7, X7 // 62911c0754bc700f000000 VANDPS X20, X31, K7, X8 // 6231040754c4 VANDPS X24, X31, K7, X8 // 6211040754c0 VANDPS X7, X31, K7, X8 // 6271040754c7 VANDPS 15(R8)(R14*1), X31, K7, X8 // 621104075484300f000000 VANDPS 15(R8)(R14*2), X31, K7, X8 // 621104075484700f000000 VANDPS X20, X3, K7, X8 // 6231640f54c4 VANDPS X24, X3, K7, X8 // 6211640f54c0 VANDPS X7, X3, K7, X8 // 6271640f54c7 VANDPS 15(R8)(R14*1), X3, K7, X8 // 6211640f5484300f000000 VANDPS 15(R8)(R14*2), X3, K7, X8 // 6211640f5484700f000000 VANDPS X20, X28, K7, X8 // 62311c0754c4 VANDPS X24, X28, K7, X8 // 62111c0754c0 VANDPS X7, X28, K7, X8 // 62711c0754c7 VANDPS 15(R8)(R14*1), X28, K7, X8 // 62111c075484300f000000 VANDPS 15(R8)(R14*2), X28, K7, X8 // 62111c075484700f000000 VANDPS Y31, Y16, K2, Y30 // 62017c2254f7 VANDPS Y22, Y16, K2, Y30 // 62217c2254f6 VANDPS Y6, Y16, K2, Y30 // 62617c2254f6 VANDPS 15(R8)(R14*4), Y16, K2, Y30 // 62017c2254b4b00f000000 VANDPS -7(CX)(DX*4), Y16, K2, Y30 // 62617c2254b491f9ffffff VANDPS Y31, Y1, K2, Y30 // 6201742a54f7 VANDPS Y22, Y1, K2, Y30 // 6221742a54f6 VANDPS Y6, Y1, K2, Y30 // 6261742a54f6 VANDPS 15(R8)(R14*4), Y1, K2, Y30 // 6201742a54b4b00f000000 VANDPS -7(CX)(DX*4), Y1, K2, Y30 // 6261742a54b491f9ffffff VANDPS Y31, Y30, K2, Y30 // 62010c2254f7 VANDPS Y22, Y30, K2, Y30 // 62210c2254f6 VANDPS Y6, Y30, K2, Y30 // 62610c2254f6 VANDPS 15(R8)(R14*4), Y30, K2, Y30 // 62010c2254b4b00f000000 VANDPS -7(CX)(DX*4), Y30, K2, Y30 // 62610c2254b491f9ffffff VANDPS Y31, Y16, K2, Y26 // 62017c2254d7 VANDPS Y22, Y16, K2, Y26 // 62217c2254d6 VANDPS Y6, Y16, K2, Y26 // 62617c2254d6 VANDPS 15(R8)(R14*4), Y16, K2, Y26 // 62017c225494b00f000000 VANDPS -7(CX)(DX*4), Y16, K2, Y26 // 62617c22549491f9ffffff VANDPS Y31, Y1, K2, Y26 // 6201742a54d7 VANDPS Y22, Y1, K2, Y26 // 6221742a54d6 VANDPS Y6, Y1, K2, Y26 // 6261742a54d6 VANDPS 15(R8)(R14*4), Y1, K2, Y26 // 6201742a5494b00f000000 VANDPS -7(CX)(DX*4), Y1, K2, Y26 // 6261742a549491f9ffffff VANDPS Y31, Y30, K2, Y26 // 62010c2254d7 VANDPS Y22, Y30, K2, Y26 // 62210c2254d6 VANDPS Y6, Y30, K2, Y26 // 62610c2254d6 VANDPS 15(R8)(R14*4), Y30, K2, Y26 // 62010c225494b00f000000 VANDPS -7(CX)(DX*4), Y30, K2, Y26 // 62610c22549491f9ffffff VANDPS Y31, Y16, K2, Y7 // 62917c2254ff VANDPS Y22, Y16, K2, Y7 // 62b17c2254fe VANDPS Y6, Y16, K2, Y7 // 62f17c2254fe VANDPS 15(R8)(R14*4), Y16, K2, Y7 // 62917c2254bcb00f000000 VANDPS -7(CX)(DX*4), Y16, K2, Y7 // 62f17c2254bc91f9ffffff VANDPS Y31, Y1, K2, Y7 // 6291742a54ff VANDPS Y22, Y1, K2, Y7 // 62b1742a54fe VANDPS Y6, Y1, K2, Y7 // 62f1742a54fe VANDPS 15(R8)(R14*4), Y1, K2, Y7 // 6291742a54bcb00f000000 VANDPS -7(CX)(DX*4), Y1, K2, Y7 // 62f1742a54bc91f9ffffff VANDPS Y31, Y30, K2, Y7 // 62910c2254ff VANDPS Y22, Y30, K2, Y7 // 62b10c2254fe VANDPS Y6, Y30, K2, Y7 // 62f10c2254fe VANDPS 15(R8)(R14*4), Y30, K2, Y7 // 62910c2254bcb00f000000 VANDPS -7(CX)(DX*4), Y30, K2, Y7 // 62f10c2254bc91f9ffffff VANDPS Z6, Z6, K5, Z7 // 62f14c4d54fe VANDPS Z22, Z6, K5, Z7 // 62b14c4d54fe VANDPS 15(R8)(R14*4), Z6, K5, Z7 // 62914c4d54bcb00f000000 VANDPS -7(CX)(DX*4), Z6, K5, Z7 // 62f14c4d54bc91f9ffffff VANDPS Z6, Z16, K5, Z7 // 62f17c4554fe VANDPS Z22, Z16, K5, Z7 // 62b17c4554fe VANDPS 15(R8)(R14*4), Z16, K5, Z7 // 62917c4554bcb00f000000 VANDPS -7(CX)(DX*4), Z16, K5, Z7 // 62f17c4554bc91f9ffffff VANDPS Z6, Z6, K5, Z13 // 62714c4d54ee VANDPS Z22, Z6, K5, Z13 // 62314c4d54ee VANDPS 15(R8)(R14*4), Z6, K5, Z13 // 62114c4d54acb00f000000 VANDPS -7(CX)(DX*4), Z6, K5, Z13 // 62714c4d54ac91f9ffffff VANDPS Z6, Z16, K5, Z13 // 62717c4554ee VANDPS Z22, Z16, K5, Z13 // 62317c4554ee VANDPS 15(R8)(R14*4), Z16, K5, Z13 // 62117c4554acb00f000000 VANDPS -7(CX)(DX*4), Z16, K5, Z13 // 62717c4554ac91f9ffffff VBROADCASTF32X2 X16, K3, Y1 // 62b27d2b19c8 VBROADCASTF32X2 X28, K3, Y1 // 62927d2b19cc VBROADCASTF32X2 X8, K3, Y1 // 62d27d2b19c8 VBROADCASTF32X2 -17(BP)(SI*8), K3, Y1 // 62f27d2b198cf5efffffff VBROADCASTF32X2 (R15), K3, Y1 // 62d27d2b190f VBROADCASTF32X2 X16, K3, Y27 // 62227d2b19d8 VBROADCASTF32X2 X28, K3, Y27 // 62027d2b19dc VBROADCASTF32X2 X8, K3, Y27 // 62427d2b19d8 VBROADCASTF32X2 -17(BP)(SI*8), K3, Y27 // 62627d2b199cf5efffffff VBROADCASTF32X2 (R15), K3, Y27 // 62427d2b191f VBROADCASTF32X2 X16, K3, Y19 // 62a27d2b19d8 VBROADCASTF32X2 X28, K3, Y19 // 62827d2b19dc VBROADCASTF32X2 X8, K3, Y19 // 62c27d2b19d8 VBROADCASTF32X2 -17(BP)(SI*8), K3, Y19 // 62e27d2b199cf5efffffff VBROADCASTF32X2 (R15), K3, Y19 // 62c27d2b191f VBROADCASTF32X2 X15, K2, Z1 // 62d27d4a19cf VBROADCASTF32X2 X11, K2, Z1 // 62d27d4a19cb VBROADCASTF32X2 X1, K2, Z1 // 62f27d4a19c9 VBROADCASTF32X2 7(SI)(DI*8), K2, Z1 // 62f27d4a198cfe07000000 VBROADCASTF32X2 -15(R14), K2, Z1 // 62d27d4a198ef1ffffff VBROADCASTF32X2 X15, K2, Z3 // 62d27d4a19df VBROADCASTF32X2 X11, K2, Z3 // 62d27d4a19db VBROADCASTF32X2 X1, K2, Z3 // 62f27d4a19d9 VBROADCASTF32X2 7(SI)(DI*8), K2, Z3 // 62f27d4a199cfe07000000 VBROADCASTF32X2 -15(R14), K2, Z3 // 62d27d4a199ef1ffffff VBROADCASTF32X8 -17(BP)(SI*2), K1, Z28 // 62627d491ba475efffffff VBROADCASTF32X8 7(AX)(CX*2), K1, Z28 // 62627d491ba44807000000 VBROADCASTF32X8 -17(BP)(SI*2), K1, Z13 // 62727d491bac75efffffff VBROADCASTF32X8 7(AX)(CX*2), K1, Z13 // 62727d491bac4807000000 VBROADCASTF64X2 -7(CX)(DX*1), K7, Y21 // 62e2fd2f1aac11f9ffffff VBROADCASTF64X2 -15(R14)(R15*4), K7, Y21 // 6282fd2f1aacbef1ffffff VBROADCASTF64X2 -7(CX)(DX*1), K7, Y7 // 62f2fd2f1abc11f9ffffff VBROADCASTF64X2 -15(R14)(R15*4), K7, Y7 // 6292fd2f1abcbef1ffffff VBROADCASTF64X2 -7(CX)(DX*1), K7, Y30 // 6262fd2f1ab411f9ffffff VBROADCASTF64X2 -15(R14)(R15*4), K7, Y30 // 6202fd2f1ab4bef1ffffff VBROADCASTF64X2 15(DX)(BX*1), K1, Z14 // 6272fd491ab41a0f000000 VBROADCASTF64X2 -7(CX)(DX*2), K1, Z14 // 6272fd491ab451f9ffffff VBROADCASTF64X2 15(DX)(BX*1), K1, Z28 // 6262fd491aa41a0f000000 VBROADCASTF64X2 -7(CX)(DX*2), K1, Z28 // 6262fd491aa451f9ffffff VBROADCASTI32X2 X14, K1, X19 // 62c27d0959de VBROADCASTI32X2 X0, K1, X19 // 62e27d0959d8 VBROADCASTI32X2 7(SI)(DI*1), K1, X19 // 62e27d09599c3e07000000 VBROADCASTI32X2 15(DX)(BX*8), K1, X19 // 62e27d09599cda0f000000 VBROADCASTI32X2 X14, K1, X13 // 62527d0959ee VBROADCASTI32X2 X0, K1, X13 // 62727d0959e8 VBROADCASTI32X2 7(SI)(DI*1), K1, X13 // 62727d0959ac3e07000000 VBROADCASTI32X2 15(DX)(BX*8), K1, X13 // 62727d0959acda0f000000 VBROADCASTI32X2 X14, K1, X2 // 62d27d0959d6 VBROADCASTI32X2 X0, K1, X2 // 62f27d0959d0 VBROADCASTI32X2 7(SI)(DI*1), K1, X2 // 62f27d0959943e07000000 VBROADCASTI32X2 15(DX)(BX*8), K1, X2 // 62f27d095994da0f000000 VBROADCASTI32X2 X25, K7, Y13 // 62127d2f59e9 VBROADCASTI32X2 X11, K7, Y13 // 62527d2f59eb VBROADCASTI32X2 X17, K7, Y13 // 62327d2f59e9 VBROADCASTI32X2 -7(DI)(R8*1), K7, Y13 // 62327d2f59ac07f9ffffff VBROADCASTI32X2 (SP), K7, Y13 // 62727d2f592c24 VBROADCASTI32X2 X25, K7, Y18 // 62827d2f59d1 VBROADCASTI32X2 X11, K7, Y18 // 62c27d2f59d3 VBROADCASTI32X2 X17, K7, Y18 // 62a27d2f59d1 VBROADCASTI32X2 -7(DI)(R8*1), K7, Y18 // 62a27d2f599407f9ffffff VBROADCASTI32X2 (SP), K7, Y18 // 62e27d2f591424 VBROADCASTI32X2 X25, K7, Y24 // 62027d2f59c1 VBROADCASTI32X2 X11, K7, Y24 // 62427d2f59c3 VBROADCASTI32X2 X17, K7, Y24 // 62227d2f59c1 VBROADCASTI32X2 -7(DI)(R8*1), K7, Y24 // 62227d2f598407f9ffffff VBROADCASTI32X2 (SP), K7, Y24 // 62627d2f590424 VBROADCASTI32X2 X18, K2, Z15 // 62327d4a59fa VBROADCASTI32X2 X11, K2, Z15 // 62527d4a59fb VBROADCASTI32X2 X9, K2, Z15 // 62527d4a59f9 VBROADCASTI32X2 -7(CX), K2, Z15 // 62727d4a59b9f9ffffff VBROADCASTI32X2 15(DX)(BX*4), K2, Z15 // 62727d4a59bc9a0f000000 VBROADCASTI32X2 X18, K2, Z30 // 62227d4a59f2 VBROADCASTI32X2 X11, K2, Z30 // 62427d4a59f3 VBROADCASTI32X2 X9, K2, Z30 // 62427d4a59f1 VBROADCASTI32X2 -7(CX), K2, Z30 // 62627d4a59b1f9ffffff VBROADCASTI32X2 15(DX)(BX*4), K2, Z30 // 62627d4a59b49a0f000000 VBROADCASTI32X8 (R14), K3, Z5 // 62d27d4b5b2e VBROADCASTI32X8 -7(DI)(R8*8), K3, Z5 // 62b27d4b5bacc7f9ffffff VBROADCASTI32X8 (R14), K3, Z1 // 62d27d4b5b0e VBROADCASTI32X8 -7(DI)(R8*8), K3, Z1 // 62b27d4b5b8cc7f9ffffff VBROADCASTI64X2 15(R8), K4, Y5 // 62d2fd2c5aa80f000000 VBROADCASTI64X2 (BP), K4, Y5 // 62f2fd2c5a6d00 VBROADCASTI64X2 15(R8), K4, Y24 // 6242fd2c5a800f000000 VBROADCASTI64X2 (BP), K4, Y24 // 6262fd2c5a4500 VBROADCASTI64X2 15(R8), K4, Y21 // 62c2fd2c5aa80f000000 VBROADCASTI64X2 (BP), K4, Y21 // 62e2fd2c5a6d00 VBROADCASTI64X2 15(R8)(R14*8), K5, Z3 // 6292fd4d5a9cf00f000000 VBROADCASTI64X2 -15(R14)(R15*2), K5, Z3 // 6292fd4d5a9c7ef1ffffff VBROADCASTI64X2 15(R8)(R14*8), K5, Z5 // 6292fd4d5aacf00f000000 VBROADCASTI64X2 -15(R14)(R15*2), K5, Z5 // 6292fd4d5aac7ef1ffffff VCVTPD2QQ X15, K7, X0 // 62d1fd0f7bc7 VCVTPD2QQ X11, K7, X0 // 62d1fd0f7bc3 VCVTPD2QQ X0, K7, X0 // 62f1fd0f7bc0 VCVTPD2QQ -17(BP)(SI*8), K7, X0 // 62f1fd0f7b84f5efffffff VCVTPD2QQ (R15), K7, X0 // 62d1fd0f7b07 VCVTPD2QQ X15, K7, X17 // 62c1fd0f7bcf VCVTPD2QQ X11, K7, X17 // 62c1fd0f7bcb VCVTPD2QQ X0, K7, X17 // 62e1fd0f7bc8 VCVTPD2QQ -17(BP)(SI*8), K7, X17 // 62e1fd0f7b8cf5efffffff VCVTPD2QQ (R15), K7, X17 // 62c1fd0f7b0f VCVTPD2QQ X15, K7, X7 // 62d1fd0f7bff VCVTPD2QQ X11, K7, X7 // 62d1fd0f7bfb VCVTPD2QQ X0, K7, X7 // 62f1fd0f7bf8 VCVTPD2QQ -17(BP)(SI*8), K7, X7 // 62f1fd0f7bbcf5efffffff VCVTPD2QQ (R15), K7, X7 // 62d1fd0f7b3f VCVTPD2QQ Y0, K2, Y6 // 62f1fd2a7bf0 VCVTPD2QQ Y19, K2, Y6 // 62b1fd2a7bf3 VCVTPD2QQ Y31, K2, Y6 // 6291fd2a7bf7 VCVTPD2QQ -15(R14)(R15*1), K2, Y6 // 6291fd2a7bb43ef1ffffff VCVTPD2QQ -15(BX), K2, Y6 // 62f1fd2a7bb3f1ffffff VCVTPD2QQ Y0, K2, Y1 // 62f1fd2a7bc8 VCVTPD2QQ Y19, K2, Y1 // 62b1fd2a7bcb VCVTPD2QQ Y31, K2, Y1 // 6291fd2a7bcf VCVTPD2QQ -15(R14)(R15*1), K2, Y1 // 6291fd2a7b8c3ef1ffffff VCVTPD2QQ -15(BX), K2, Y1 // 62f1fd2a7b8bf1ffffff VCVTPD2QQ Y0, K2, Y9 // 6271fd2a7bc8 VCVTPD2QQ Y19, K2, Y9 // 6231fd2a7bcb VCVTPD2QQ Y31, K2, Y9 // 6211fd2a7bcf VCVTPD2QQ -15(R14)(R15*1), K2, Y9 // 6211fd2a7b8c3ef1ffffff VCVTPD2QQ -15(BX), K2, Y9 // 6271fd2a7b8bf1ffffff VCVTPD2QQ Z12, K5, Z14 // 6251fd4d7bf4 VCVTPD2QQ Z13, K5, Z14 // 6251fd4d7bf5 VCVTPD2QQ Z12, K5, Z13 // 6251fd4d7bec VCVTPD2QQ Z13, K5, Z13 // 6251fd4d7bed VCVTPD2QQ Z2, K3, Z21 // 62e1fd4b7bea VCVTPD2QQ Z7, K3, Z21 // 62e1fd4b7bef VCVTPD2QQ -17(BP), K3, Z21 // 62e1fd4b7badefffffff VCVTPD2QQ -15(R14)(R15*8), K3, Z21 // 6281fd4b7bacfef1ffffff VCVTPD2QQ Z2, K3, Z9 // 6271fd4b7bca VCVTPD2QQ Z7, K3, Z9 // 6271fd4b7bcf VCVTPD2QQ -17(BP), K3, Z9 // 6271fd4b7b8defffffff VCVTPD2QQ -15(R14)(R15*8), K3, Z9 // 6211fd4b7b8cfef1ffffff VCVTPD2UQQ X24, K3, X7 // 6291fd0b79f8 VCVTPD2UQQ X7, K3, X7 // 62f1fd0b79ff VCVTPD2UQQ X0, K3, X7 // 62f1fd0b79f8 VCVTPD2UQQ 7(SI)(DI*1), K3, X7 // 62f1fd0b79bc3e07000000 VCVTPD2UQQ 15(DX)(BX*8), K3, X7 // 62f1fd0b79bcda0f000000 VCVTPD2UQQ X24, K3, X13 // 6211fd0b79e8 VCVTPD2UQQ X7, K3, X13 // 6271fd0b79ef VCVTPD2UQQ X0, K3, X13 // 6271fd0b79e8 VCVTPD2UQQ 7(SI)(DI*1), K3, X13 // 6271fd0b79ac3e07000000 VCVTPD2UQQ 15(DX)(BX*8), K3, X13 // 6271fd0b79acda0f000000 VCVTPD2UQQ X24, K3, X8 // 6211fd0b79c0 VCVTPD2UQQ X7, K3, X8 // 6271fd0b79c7 VCVTPD2UQQ X0, K3, X8 // 6271fd0b79c0 VCVTPD2UQQ 7(SI)(DI*1), K3, X8 // 6271fd0b79843e07000000 VCVTPD2UQQ 15(DX)(BX*8), K3, X8 // 6271fd0b7984da0f000000 VCVTPD2UQQ Y27, K3, Y28 // 6201fd2b79e3 VCVTPD2UQQ Y0, K3, Y28 // 6261fd2b79e0 VCVTPD2UQQ Y11, K3, Y28 // 6241fd2b79e3 VCVTPD2UQQ (SI), K3, Y28 // 6261fd2b7926 VCVTPD2UQQ 7(SI)(DI*2), K3, Y28 // 6261fd2b79a47e07000000 VCVTPD2UQQ Y27, K3, Y2 // 6291fd2b79d3 VCVTPD2UQQ Y0, K3, Y2 // 62f1fd2b79d0 VCVTPD2UQQ Y11, K3, Y2 // 62d1fd2b79d3 VCVTPD2UQQ (SI), K3, Y2 // 62f1fd2b7916 VCVTPD2UQQ 7(SI)(DI*2), K3, Y2 // 62f1fd2b79947e07000000 VCVTPD2UQQ Y27, K3, Y24 // 6201fd2b79c3 VCVTPD2UQQ Y0, K3, Y24 // 6261fd2b79c0 VCVTPD2UQQ Y11, K3, Y24 // 6241fd2b79c3 VCVTPD2UQQ (SI), K3, Y24 // 6261fd2b7906 VCVTPD2UQQ 7(SI)(DI*2), K3, Y24 // 6261fd2b79847e07000000 VCVTPD2UQQ Z3, K2, Z27 // 6261fd4a79db VCVTPD2UQQ Z0, K2, Z27 // 6261fd4a79d8 VCVTPD2UQQ Z3, K2, Z14 // 6271fd4a79f3 VCVTPD2UQQ Z0, K2, Z14 // 6271fd4a79f0 VCVTPD2UQQ Z8, K1, Z14 // 6251fd4979f0 VCVTPD2UQQ Z24, K1, Z14 // 6211fd4979f0 VCVTPD2UQQ 15(R8), K1, Z14 // 6251fd4979b00f000000 VCVTPD2UQQ (BP), K1, Z14 // 6271fd49797500 VCVTPD2UQQ Z8, K1, Z7 // 62d1fd4979f8 VCVTPD2UQQ Z24, K1, Z7 // 6291fd4979f8 VCVTPD2UQQ 15(R8), K1, Z7 // 62d1fd4979b80f000000 VCVTPD2UQQ (BP), K1, Z7 // 62f1fd49797d00 VCVTPS2QQ X19, K3, X15 // 62317d0b7bfb VCVTPS2QQ X13, K3, X15 // 62517d0b7bfd VCVTPS2QQ X2, K3, X15 // 62717d0b7bfa VCVTPS2QQ (BX), K3, X15 // 62717d0b7b3b VCVTPS2QQ -17(BP)(SI*1), K3, X15 // 62717d0b7bbc35efffffff VCVTPS2QQ X19, K3, X11 // 62317d0b7bdb VCVTPS2QQ X13, K3, X11 // 62517d0b7bdd VCVTPS2QQ X2, K3, X11 // 62717d0b7bda VCVTPS2QQ (BX), K3, X11 // 62717d0b7b1b VCVTPS2QQ -17(BP)(SI*1), K3, X11 // 62717d0b7b9c35efffffff VCVTPS2QQ X19, K3, X1 // 62b17d0b7bcb VCVTPS2QQ X13, K3, X1 // 62d17d0b7bcd VCVTPS2QQ X2, K3, X1 // 62f17d0b7bca VCVTPS2QQ (BX), K3, X1 // 62f17d0b7b0b VCVTPS2QQ -17(BP)(SI*1), K3, X1 // 62f17d0b7b8c35efffffff VCVTPS2QQ X14, K7, Y20 // 62c17d2f7be6 VCVTPS2QQ X0, K7, Y20 // 62e17d2f7be0 VCVTPS2QQ 99(R15)(R15*1), K7, Y20 // 62817d2f7ba43f63000000 VCVTPS2QQ (DX), K7, Y20 // 62e17d2f7b22 VCVTPS2QQ X14, K7, Y12 // 62517d2f7be6 VCVTPS2QQ X0, K7, Y12 // 62717d2f7be0 VCVTPS2QQ 99(R15)(R15*1), K7, Y12 // 62117d2f7ba43f63000000 VCVTPS2QQ (DX), K7, Y12 // 62717d2f7b22 VCVTPS2QQ X14, K7, Y3 // 62d17d2f7bde VCVTPS2QQ X0, K7, Y3 // 62f17d2f7bd8 VCVTPS2QQ 99(R15)(R15*1), K7, Y3 // 62917d2f7b9c3f63000000 VCVTPS2QQ (DX), K7, Y3 // 62f17d2f7b1a VCVTPS2QQ Y5, K4, Z6 // 62f17d4c7bf5 VCVTPS2QQ Y28, K4, Z6 // 62917d4c7bf4 VCVTPS2QQ Y7, K4, Z6 // 62f17d4c7bf7 VCVTPS2QQ Y5, K4, Z14 // 62717d4c7bf5 VCVTPS2QQ Y28, K4, Z14 // 62117d4c7bf4 VCVTPS2QQ Y7, K4, Z14 // 62717d4c7bf7 VCVTPS2QQ Y0, K4, Z26 // 62617d4c7bd0 VCVTPS2QQ Y22, K4, Z26 // 62217d4c7bd6 VCVTPS2QQ Y13, K4, Z26 // 62417d4c7bd5 VCVTPS2QQ 7(AX)(CX*4), K4, Z26 // 62617d4c7b948807000000 VCVTPS2QQ 7(AX)(CX*1), K4, Z26 // 62617d4c7b940807000000 VCVTPS2QQ Y0, K4, Z14 // 62717d4c7bf0 VCVTPS2QQ Y22, K4, Z14 // 62317d4c7bf6 VCVTPS2QQ Y13, K4, Z14 // 62517d4c7bf5 VCVTPS2QQ 7(AX)(CX*4), K4, Z14 // 62717d4c7bb48807000000 VCVTPS2QQ 7(AX)(CX*1), K4, Z14 // 62717d4c7bb40807000000 VCVTPS2UQQ X2, K4, X2 // 62f17d0c79d2 VCVTPS2UQQ X27, K4, X2 // 62917d0c79d3 VCVTPS2UQQ X26, K4, X2 // 62917d0c79d2 VCVTPS2UQQ (R8), K4, X2 // 62d17d0c7910 VCVTPS2UQQ 15(DX)(BX*2), K4, X2 // 62f17d0c79945a0f000000 VCVTPS2UQQ X2, K4, X24 // 62617d0c79c2 VCVTPS2UQQ X27, K4, X24 // 62017d0c79c3 VCVTPS2UQQ X26, K4, X24 // 62017d0c79c2 VCVTPS2UQQ (R8), K4, X24 // 62417d0c7900 VCVTPS2UQQ 15(DX)(BX*2), K4, X24 // 62617d0c79845a0f000000 VCVTPS2UQQ X22, K2, Y31 // 62217d2a79fe VCVTPS2UQQ X30, K2, Y31 // 62017d2a79fe VCVTPS2UQQ X3, K2, Y31 // 62617d2a79fb VCVTPS2UQQ 7(SI)(DI*8), K2, Y31 // 62617d2a79bcfe07000000 VCVTPS2UQQ -15(R14), K2, Y31 // 62417d2a79bef1ffffff VCVTPS2UQQ X22, K2, Y8 // 62317d2a79c6 VCVTPS2UQQ X30, K2, Y8 // 62117d2a79c6 VCVTPS2UQQ X3, K2, Y8 // 62717d2a79c3 VCVTPS2UQQ 7(SI)(DI*8), K2, Y8 // 62717d2a7984fe07000000 VCVTPS2UQQ -15(R14), K2, Y8 // 62517d2a7986f1ffffff VCVTPS2UQQ X22, K2, Y1 // 62b17d2a79ce VCVTPS2UQQ X30, K2, Y1 // 62917d2a79ce VCVTPS2UQQ X3, K2, Y1 // 62f17d2a79cb VCVTPS2UQQ 7(SI)(DI*8), K2, Y1 // 62f17d2a798cfe07000000 VCVTPS2UQQ -15(R14), K2, Y1 // 62d17d2a798ef1ffffff VCVTPS2UQQ Y28, K2, Z21 // 62817d4a79ec VCVTPS2UQQ Y13, K2, Z21 // 62c17d4a79ed VCVTPS2UQQ Y7, K2, Z21 // 62e17d4a79ef VCVTPS2UQQ Y28, K2, Z13 // 62117d4a79ec VCVTPS2UQQ Y13, K2, Z13 // 62517d4a79ed VCVTPS2UQQ Y7, K2, Z13 // 62717d4a79ef VCVTPS2UQQ Y2, K3, Z11 // 62717d4b79da VCVTPS2UQQ Y21, K3, Z11 // 62317d4b79dd VCVTPS2UQQ Y12, K3, Z11 // 62517d4b79dc VCVTPS2UQQ 17(SP)(BP*8), K3, Z11 // 62717d4b799cec11000000 VCVTPS2UQQ 17(SP)(BP*4), K3, Z11 // 62717d4b799cac11000000 VCVTPS2UQQ Y2, K3, Z25 // 62617d4b79ca VCVTPS2UQQ Y21, K3, Z25 // 62217d4b79cd VCVTPS2UQQ Y12, K3, Z25 // 62417d4b79cc VCVTPS2UQQ 17(SP)(BP*8), K3, Z25 // 62617d4b798cec11000000 VCVTPS2UQQ 17(SP)(BP*4), K3, Z25 // 62617d4b798cac11000000 VCVTQQ2PD X13, K3, X11 // 6251fe0be6dd VCVTQQ2PD X6, K3, X11 // 6271fe0be6de VCVTQQ2PD X12, K3, X11 // 6251fe0be6dc VCVTQQ2PD 17(SP)(BP*1), K3, X11 // 6271fe0be69c2c11000000 VCVTQQ2PD -7(CX)(DX*8), K3, X11 // 6271fe0be69cd1f9ffffff VCVTQQ2PD X13, K3, X15 // 6251fe0be6fd VCVTQQ2PD X6, K3, X15 // 6271fe0be6fe VCVTQQ2PD X12, K3, X15 // 6251fe0be6fc VCVTQQ2PD 17(SP)(BP*1), K3, X15 // 6271fe0be6bc2c11000000 VCVTQQ2PD -7(CX)(DX*8), K3, X15 // 6271fe0be6bcd1f9ffffff VCVTQQ2PD X13, K3, X30 // 6241fe0be6f5 VCVTQQ2PD X6, K3, X30 // 6261fe0be6f6 VCVTQQ2PD X12, K3, X30 // 6241fe0be6f4 VCVTQQ2PD 17(SP)(BP*1), K3, X30 // 6261fe0be6b42c11000000 VCVTQQ2PD -7(CX)(DX*8), K3, X30 // 6261fe0be6b4d1f9ffffff VCVTQQ2PD Y3, K3, Y9 // 6271fe2be6cb VCVTQQ2PD Y2, K3, Y9 // 6271fe2be6ca VCVTQQ2PD Y9, K3, Y9 // 6251fe2be6c9 VCVTQQ2PD 7(SI)(DI*1), K3, Y9 // 6271fe2be68c3e07000000 VCVTQQ2PD 15(DX)(BX*8), K3, Y9 // 6271fe2be68cda0f000000 VCVTQQ2PD Y3, K3, Y1 // 62f1fe2be6cb VCVTQQ2PD Y2, K3, Y1 // 62f1fe2be6ca VCVTQQ2PD Y9, K3, Y1 // 62d1fe2be6c9 VCVTQQ2PD 7(SI)(DI*1), K3, Y1 // 62f1fe2be68c3e07000000 VCVTQQ2PD 15(DX)(BX*8), K3, Y1 // 62f1fe2be68cda0f000000 VCVTQQ2PD Z27, K2, Z3 // 6291fe4ae6db VCVTQQ2PD Z15, K2, Z3 // 62d1fe4ae6df VCVTQQ2PD Z27, K2, Z12 // 6211fe4ae6e3 VCVTQQ2PD Z15, K2, Z12 // 6251fe4ae6e7 VCVTQQ2PD Z23, K1, Z23 // 62a1fe49e6ff VCVTQQ2PD Z6, K1, Z23 // 62e1fe49e6fe VCVTQQ2PD 7(SI)(DI*4), K1, Z23 // 62e1fe49e6bcbe07000000 VCVTQQ2PD -7(DI)(R8*2), K1, Z23 // 62a1fe49e6bc47f9ffffff VCVTQQ2PD Z23, K1, Z5 // 62b1fe49e6ef VCVTQQ2PD Z6, K1, Z5 // 62f1fe49e6ee VCVTQQ2PD 7(SI)(DI*4), K1, Z5 // 62f1fe49e6acbe07000000 VCVTQQ2PD -7(DI)(R8*2), K1, Z5 // 62b1fe49e6ac47f9ffffff VCVTQQ2PS Z8, K2, Y12 // 6251fc4a5be0 VCVTQQ2PS Z28, K2, Y12 // 6211fc4a5be4 VCVTQQ2PS Z8, K2, Y21 // 62c1fc4a5be8 VCVTQQ2PS Z28, K2, Y21 // 6281fc4a5bec VCVTQQ2PS Z8, K2, Y14 // 6251fc4a5bf0 VCVTQQ2PS Z28, K2, Y14 // 6211fc4a5bf4 VCVTQQ2PS Z21, K1, Y30 // 6221fc495bf5 VCVTQQ2PS Z5, K1, Y30 // 6261fc495bf5 VCVTQQ2PS 17(SP), K1, Y30 // 6261fc495bb42411000000 VCVTQQ2PS -17(BP)(SI*4), K1, Y30 // 6261fc495bb4b5efffffff VCVTQQ2PS Z21, K1, Y26 // 6221fc495bd5 VCVTQQ2PS Z5, K1, Y26 // 6261fc495bd5 VCVTQQ2PS 17(SP), K1, Y26 // 6261fc495b942411000000 VCVTQQ2PS -17(BP)(SI*4), K1, Y26 // 6261fc495b94b5efffffff VCVTQQ2PS Z21, K1, Y7 // 62b1fc495bfd VCVTQQ2PS Z5, K1, Y7 // 62f1fc495bfd VCVTQQ2PS 17(SP), K1, Y7 // 62f1fc495bbc2411000000 VCVTQQ2PS -17(BP)(SI*4), K1, Y7 // 62f1fc495bbcb5efffffff VCVTQQ2PSX X20, K7, X23 // 62a1fc0f5bfc VCVTQQ2PSX X2, K7, X23 // 62e1fc0f5bfa VCVTQQ2PSX X9, K7, X23 // 62c1fc0f5bf9 VCVTQQ2PSX -17(BP)(SI*2), K7, X23 // 62e1fc0f5bbc75efffffff VCVTQQ2PSX 7(AX)(CX*2), K7, X23 // 62e1fc0f5bbc4807000000 VCVTQQ2PSX X20, K7, X30 // 6221fc0f5bf4 VCVTQQ2PSX X2, K7, X30 // 6261fc0f5bf2 VCVTQQ2PSX X9, K7, X30 // 6241fc0f5bf1 VCVTQQ2PSX -17(BP)(SI*2), K7, X30 // 6261fc0f5bb475efffffff VCVTQQ2PSX 7(AX)(CX*2), K7, X30 // 6261fc0f5bb44807000000 VCVTQQ2PSX X20, K7, X8 // 6231fc0f5bc4 VCVTQQ2PSX X2, K7, X8 // 6271fc0f5bc2 VCVTQQ2PSX X9, K7, X8 // 6251fc0f5bc1 VCVTQQ2PSX -17(BP)(SI*2), K7, X8 // 6271fc0f5b8475efffffff VCVTQQ2PSX 7(AX)(CX*2), K7, X8 // 6271fc0f5b844807000000 VCVTQQ2PSY Y16, K1, X26 // 6221fc295bd0 VCVTQQ2PSY Y1, K1, X26 // 6261fc295bd1 VCVTQQ2PSY Y30, K1, X26 // 6201fc295bd6 VCVTQQ2PSY -7(DI)(R8*1), K1, X26 // 6221fc295b9407f9ffffff VCVTQQ2PSY (SP), K1, X26 // 6261fc295b1424 VCVTQQ2PSY Y16, K1, X19 // 62a1fc295bd8 VCVTQQ2PSY Y1, K1, X19 // 62e1fc295bd9 VCVTQQ2PSY Y30, K1, X19 // 6281fc295bde VCVTQQ2PSY -7(DI)(R8*1), K1, X19 // 62a1fc295b9c07f9ffffff VCVTQQ2PSY (SP), K1, X19 // 62e1fc295b1c24 VCVTQQ2PSY Y16, K1, X0 // 62b1fc295bc0 VCVTQQ2PSY Y1, K1, X0 // 62f1fc295bc1 VCVTQQ2PSY Y30, K1, X0 // 6291fc295bc6 VCVTQQ2PSY -7(DI)(R8*1), K1, X0 // 62b1fc295b8407f9ffffff VCVTQQ2PSY (SP), K1, X0 // 62f1fc295b0424 VCVTTPD2QQ X6, K5, X6 // 62f1fd0d7af6 VCVTTPD2QQ X1, K5, X6 // 62f1fd0d7af1 VCVTTPD2QQ X8, K5, X6 // 62d1fd0d7af0 VCVTTPD2QQ (R14), K5, X6 // 62d1fd0d7a36 VCVTTPD2QQ -7(DI)(R8*8), K5, X6 // 62b1fd0d7ab4c7f9ffffff VCVTTPD2QQ X6, K5, X17 // 62e1fd0d7ace VCVTTPD2QQ X1, K5, X17 // 62e1fd0d7ac9 VCVTTPD2QQ X8, K5, X17 // 62c1fd0d7ac8 VCVTTPD2QQ (R14), K5, X17 // 62c1fd0d7a0e VCVTTPD2QQ -7(DI)(R8*8), K5, X17 // 62a1fd0d7a8cc7f9ffffff VCVTTPD2QQ X6, K5, X28 // 6261fd0d7ae6 VCVTTPD2QQ X1, K5, X28 // 6261fd0d7ae1 VCVTTPD2QQ X8, K5, X28 // 6241fd0d7ae0 VCVTTPD2QQ (R14), K5, X28 // 6241fd0d7a26 VCVTTPD2QQ -7(DI)(R8*8), K5, X28 // 6221fd0d7aa4c7f9ffffff VCVTTPD2QQ Y14, K7, Y24 // 6241fd2f7ac6 VCVTTPD2QQ Y21, K7, Y24 // 6221fd2f7ac5 VCVTTPD2QQ Y1, K7, Y24 // 6261fd2f7ac1 VCVTTPD2QQ 99(R15)(R15*8), K7, Y24 // 6201fd2f7a84ff63000000 VCVTTPD2QQ 7(AX)(CX*8), K7, Y24 // 6261fd2f7a84c807000000 VCVTTPD2QQ Y14, K7, Y13 // 6251fd2f7aee VCVTTPD2QQ Y21, K7, Y13 // 6231fd2f7aed VCVTTPD2QQ Y1, K7, Y13 // 6271fd2f7ae9 VCVTTPD2QQ 99(R15)(R15*8), K7, Y13 // 6211fd2f7aacff63000000 VCVTTPD2QQ 7(AX)(CX*8), K7, Y13 // 6271fd2f7aacc807000000 VCVTTPD2QQ Y14, K7, Y20 // 62c1fd2f7ae6 VCVTTPD2QQ Y21, K7, Y20 // 62a1fd2f7ae5 VCVTTPD2QQ Y1, K7, Y20 // 62e1fd2f7ae1 VCVTTPD2QQ 99(R15)(R15*8), K7, Y20 // 6281fd2f7aa4ff63000000 VCVTTPD2QQ 7(AX)(CX*8), K7, Y20 // 62e1fd2f7aa4c807000000 VCVTTPD2QQ Z6, K7, Z22 // 62e1fd4f7af6 VCVTTPD2QQ Z8, K7, Z22 // 62c1fd4f7af0 VCVTTPD2QQ Z6, K7, Z11 // 6271fd4f7ade VCVTTPD2QQ Z8, K7, Z11 // 6251fd4f7ad8 VCVTTPD2QQ Z12, K6, Z25 // 6241fd4e7acc VCVTTPD2QQ Z17, K6, Z25 // 6221fd4e7ac9 VCVTTPD2QQ 99(R15)(R15*1), K6, Z25 // 6201fd4e7a8c3f63000000 VCVTTPD2QQ (DX), K6, Z25 // 6261fd4e7a0a VCVTTPD2QQ Z12, K6, Z12 // 6251fd4e7ae4 VCVTTPD2QQ Z17, K6, Z12 // 6231fd4e7ae1 VCVTTPD2QQ 99(R15)(R15*1), K6, Z12 // 6211fd4e7aa43f63000000 VCVTTPD2QQ (DX), K6, Z12 // 6271fd4e7a22 VCVTTPD2UQQ X15, K7, X16 // 62c1fd0f78c7 VCVTTPD2UQQ X11, K7, X16 // 62c1fd0f78c3 VCVTTPD2UQQ X1, K7, X16 // 62e1fd0f78c1 VCVTTPD2UQQ (CX), K7, X16 // 62e1fd0f7801 VCVTTPD2UQQ 99(R15), K7, X16 // 62c1fd0f788763000000 VCVTTPD2UQQ X15, K7, X28 // 6241fd0f78e7 VCVTTPD2UQQ X11, K7, X28 // 6241fd0f78e3 VCVTTPD2UQQ X1, K7, X28 // 6261fd0f78e1 VCVTTPD2UQQ (CX), K7, X28 // 6261fd0f7821 VCVTTPD2UQQ 99(R15), K7, X28 // 6241fd0f78a763000000 VCVTTPD2UQQ X15, K7, X8 // 6251fd0f78c7 VCVTTPD2UQQ X11, K7, X8 // 6251fd0f78c3 VCVTTPD2UQQ X1, K7, X8 // 6271fd0f78c1 VCVTTPD2UQQ (CX), K7, X8 // 6271fd0f7801 VCVTTPD2UQQ 99(R15), K7, X8 // 6251fd0f788763000000 VCVTTPD2UQQ Y21, K2, Y5 // 62b1fd2a78ed VCVTTPD2UQQ Y7, K2, Y5 // 62f1fd2a78ef VCVTTPD2UQQ Y30, K2, Y5 // 6291fd2a78ee VCVTTPD2UQQ (BX), K2, Y5 // 62f1fd2a782b VCVTTPD2UQQ -17(BP)(SI*1), K2, Y5 // 62f1fd2a78ac35efffffff VCVTTPD2UQQ Y21, K2, Y17 // 62a1fd2a78cd VCVTTPD2UQQ Y7, K2, Y17 // 62e1fd2a78cf VCVTTPD2UQQ Y30, K2, Y17 // 6281fd2a78ce VCVTTPD2UQQ (BX), K2, Y17 // 62e1fd2a780b VCVTTPD2UQQ -17(BP)(SI*1), K2, Y17 // 62e1fd2a788c35efffffff VCVTTPD2UQQ Y21, K2, Y13 // 6231fd2a78ed VCVTTPD2UQQ Y7, K2, Y13 // 6271fd2a78ef VCVTTPD2UQQ Y30, K2, Y13 // 6211fd2a78ee VCVTTPD2UQQ (BX), K2, Y13 // 6271fd2a782b VCVTTPD2UQQ -17(BP)(SI*1), K2, Y13 // 6271fd2a78ac35efffffff VCVTTPD2UQQ Z8, K5, Z3 // 62d1fd4d78d8 VCVTTPD2UQQ Z2, K5, Z3 // 62f1fd4d78da VCVTTPD2UQQ Z8, K5, Z21 // 62c1fd4d78e8 VCVTTPD2UQQ Z2, K5, Z21 // 62e1fd4d78ea VCVTTPD2UQQ Z7, K3, Z3 // 62f1fd4b78df VCVTTPD2UQQ Z9, K3, Z3 // 62d1fd4b78d9 VCVTTPD2UQQ 7(SI)(DI*8), K3, Z3 // 62f1fd4b789cfe07000000 VCVTTPD2UQQ -15(R14), K3, Z3 // 62d1fd4b789ef1ffffff VCVTTPD2UQQ Z7, K3, Z27 // 6261fd4b78df VCVTTPD2UQQ Z9, K3, Z27 // 6241fd4b78d9 VCVTTPD2UQQ 7(SI)(DI*8), K3, Z27 // 6261fd4b789cfe07000000 VCVTTPD2UQQ -15(R14), K3, Z27 // 6241fd4b789ef1ffffff VCVTTPS2QQ X18, K3, X25 // 62217d0b7aca VCVTTPS2QQ X11, K3, X25 // 62417d0b7acb VCVTTPS2QQ X9, K3, X25 // 62417d0b7ac9 VCVTTPS2QQ -7(CX)(DX*1), K3, X25 // 62617d0b7a8c11f9ffffff VCVTTPS2QQ -15(R14)(R15*4), K3, X25 // 62017d0b7a8cbef1ffffff VCVTTPS2QQ X18, K3, X11 // 62317d0b7ada VCVTTPS2QQ X11, K3, X11 // 62517d0b7adb VCVTTPS2QQ X9, K3, X11 // 62517d0b7ad9 VCVTTPS2QQ -7(CX)(DX*1), K3, X11 // 62717d0b7a9c11f9ffffff VCVTTPS2QQ -15(R14)(R15*4), K3, X11 // 62117d0b7a9cbef1ffffff VCVTTPS2QQ X18, K3, X17 // 62a17d0b7aca VCVTTPS2QQ X11, K3, X17 // 62c17d0b7acb VCVTTPS2QQ X9, K3, X17 // 62c17d0b7ac9 VCVTTPS2QQ -7(CX)(DX*1), K3, X17 // 62e17d0b7a8c11f9ffffff VCVTTPS2QQ -15(R14)(R15*4), K3, X17 // 62817d0b7a8cbef1ffffff VCVTTPS2QQ X2, K3, Y5 // 62f17d2b7aea VCVTTPS2QQ X24, K3, Y5 // 62917d2b7ae8 VCVTTPS2QQ (R8), K3, Y5 // 62d17d2b7a28 VCVTTPS2QQ 15(DX)(BX*2), K3, Y5 // 62f17d2b7aac5a0f000000 VCVTTPS2QQ X2, K3, Y24 // 62617d2b7ac2 VCVTTPS2QQ X24, K3, Y24 // 62017d2b7ac0 VCVTTPS2QQ (R8), K3, Y24 // 62417d2b7a00 VCVTTPS2QQ 15(DX)(BX*2), K3, Y24 // 62617d2b7a845a0f000000 VCVTTPS2QQ X2, K3, Y21 // 62e17d2b7aea VCVTTPS2QQ X24, K3, Y21 // 62817d2b7ae8 VCVTTPS2QQ (R8), K3, Y21 // 62c17d2b7a28 VCVTTPS2QQ 15(DX)(BX*2), K3, Y21 // 62e17d2b7aac5a0f000000 VCVTTPS2QQ Y16, K2, Z12 // 62317d4a7ae0 VCVTTPS2QQ Y9, K2, Z12 // 62517d4a7ae1 VCVTTPS2QQ Y13, K2, Z12 // 62517d4a7ae5 VCVTTPS2QQ Y16, K2, Z22 // 62a17d4a7af0 VCVTTPS2QQ Y9, K2, Z22 // 62c17d4a7af1 VCVTTPS2QQ Y13, K2, Z22 // 62c17d4a7af5 VCVTTPS2QQ Y9, K1, Z11 // 62517d497ad9 VCVTTPS2QQ Y6, K1, Z11 // 62717d497ade VCVTTPS2QQ Y3, K1, Z11 // 62717d497adb VCVTTPS2QQ -7(DI)(R8*1), K1, Z11 // 62317d497a9c07f9ffffff VCVTTPS2QQ (SP), K1, Z11 // 62717d497a1c24 VCVTTPS2QQ Y9, K1, Z5 // 62d17d497ae9 VCVTTPS2QQ Y6, K1, Z5 // 62f17d497aee VCVTTPS2QQ Y3, K1, Z5 // 62f17d497aeb VCVTTPS2QQ -7(DI)(R8*1), K1, Z5 // 62b17d497aac07f9ffffff VCVTTPS2QQ (SP), K1, Z5 // 62f17d497a2c24 VCVTTPS2UQQ X13, K1, X11 // 62517d0978dd VCVTTPS2UQQ X6, K1, X11 // 62717d0978de VCVTTPS2UQQ X12, K1, X11 // 62517d0978dc VCVTTPS2UQQ -17(BP), K1, X11 // 62717d09789defffffff VCVTTPS2UQQ -15(R14)(R15*8), K1, X11 // 62117d09789cfef1ffffff VCVTTPS2UQQ X13, K1, X15 // 62517d0978fd VCVTTPS2UQQ X6, K1, X15 // 62717d0978fe VCVTTPS2UQQ X12, K1, X15 // 62517d0978fc VCVTTPS2UQQ -17(BP), K1, X15 // 62717d0978bdefffffff VCVTTPS2UQQ -15(R14)(R15*8), K1, X15 // 62117d0978bcfef1ffffff VCVTTPS2UQQ X13, K1, X30 // 62417d0978f5 VCVTTPS2UQQ X6, K1, X30 // 62617d0978f6 VCVTTPS2UQQ X12, K1, X30 // 62417d0978f4 VCVTTPS2UQQ -17(BP), K1, X30 // 62617d0978b5efffffff VCVTTPS2UQQ -15(R14)(R15*8), K1, X30 // 62017d0978b4fef1ffffff VCVTTPS2UQQ X23, K1, Y14 // 62317d2978f7 VCVTTPS2UQQ X30, K1, Y14 // 62117d2978f6 VCVTTPS2UQQ X8, K1, Y14 // 62517d2978f0 VCVTTPS2UQQ -17(BP)(SI*2), K1, Y14 // 62717d2978b475efffffff VCVTTPS2UQQ 7(AX)(CX*2), K1, Y14 // 62717d2978b44807000000 VCVTTPS2UQQ X23, K1, Y18 // 62a17d2978d7 VCVTTPS2UQQ X30, K1, Y18 // 62817d2978d6 VCVTTPS2UQQ X8, K1, Y18 // 62c17d2978d0 VCVTTPS2UQQ -17(BP)(SI*2), K1, Y18 // 62e17d29789475efffffff VCVTTPS2UQQ 7(AX)(CX*2), K1, Y18 // 62e17d2978944807000000 VCVTTPS2UQQ X23, K1, Y31 // 62217d2978ff VCVTTPS2UQQ X30, K1, Y31 // 62017d2978fe VCVTTPS2UQQ X8, K1, Y31 // 62417d2978f8 VCVTTPS2UQQ -17(BP)(SI*2), K1, Y31 // 62617d2978bc75efffffff VCVTTPS2UQQ 7(AX)(CX*2), K1, Y31 // 62617d2978bc4807000000 VCVTTPS2UQQ Y18, K7, Z6 // 62b17d4f78f2 VCVTTPS2UQQ Y3, K7, Z6 // 62f17d4f78f3 VCVTTPS2UQQ Y24, K7, Z6 // 62917d4f78f0 VCVTTPS2UQQ Y18, K7, Z22 // 62a17d4f78f2 VCVTTPS2UQQ Y3, K7, Z22 // 62e17d4f78f3 VCVTTPS2UQQ Y24, K7, Z22 // 62817d4f78f0 VCVTTPS2UQQ Y2, K2, Z1 // 62f17d4a78ca VCVTTPS2UQQ Y7, K2, Z1 // 62f17d4a78cf VCVTTPS2UQQ Y21, K2, Z1 // 62b17d4a78cd VCVTTPS2UQQ 99(R15)(R15*8), K2, Z1 // 62917d4a788cff63000000 VCVTTPS2UQQ 7(AX)(CX*8), K2, Z1 // 62f17d4a788cc807000000 VCVTTPS2UQQ Y2, K2, Z15 // 62717d4a78fa VCVTTPS2UQQ Y7, K2, Z15 // 62717d4a78ff VCVTTPS2UQQ Y21, K2, Z15 // 62317d4a78fd VCVTTPS2UQQ 99(R15)(R15*8), K2, Z15 // 62117d4a78bcff63000000 VCVTTPS2UQQ 7(AX)(CX*8), K2, Z15 // 62717d4a78bcc807000000 VCVTUQQ2PD X13, K6, X21 // 62c1fe0e7aed VCVTUQQ2PD X0, K6, X21 // 62e1fe0e7ae8 VCVTUQQ2PD X30, K6, X21 // 6281fe0e7aee VCVTUQQ2PD 15(R8)(R14*8), K6, X21 // 6281fe0e7aacf00f000000 VCVTUQQ2PD -15(R14)(R15*2), K6, X21 // 6281fe0e7aac7ef1ffffff VCVTUQQ2PD X13, K6, X1 // 62d1fe0e7acd VCVTUQQ2PD X0, K6, X1 // 62f1fe0e7ac8 VCVTUQQ2PD X30, K6, X1 // 6291fe0e7ace VCVTUQQ2PD 15(R8)(R14*8), K6, X1 // 6291fe0e7a8cf00f000000 VCVTUQQ2PD -15(R14)(R15*2), K6, X1 // 6291fe0e7a8c7ef1ffffff VCVTUQQ2PD X13, K6, X11 // 6251fe0e7add VCVTUQQ2PD X0, K6, X11 // 6271fe0e7ad8 VCVTUQQ2PD X30, K6, X11 // 6211fe0e7ade VCVTUQQ2PD 15(R8)(R14*8), K6, X11 // 6211fe0e7a9cf00f000000 VCVTUQQ2PD -15(R14)(R15*2), K6, X11 // 6211fe0e7a9c7ef1ffffff VCVTUQQ2PD Y11, K3, Y28 // 6241fe2b7ae3 VCVTUQQ2PD Y27, K3, Y28 // 6201fe2b7ae3 VCVTUQQ2PD Y17, K3, Y28 // 6221fe2b7ae1 VCVTUQQ2PD 99(R15)(R15*4), K3, Y28 // 6201fe2b7aa4bf63000000 VCVTUQQ2PD 15(DX), K3, Y28 // 6261fe2b7aa20f000000 VCVTUQQ2PD Y11, K3, Y1 // 62d1fe2b7acb VCVTUQQ2PD Y27, K3, Y1 // 6291fe2b7acb VCVTUQQ2PD Y17, K3, Y1 // 62b1fe2b7ac9 VCVTUQQ2PD 99(R15)(R15*4), K3, Y1 // 6291fe2b7a8cbf63000000 VCVTUQQ2PD 15(DX), K3, Y1 // 62f1fe2b7a8a0f000000 VCVTUQQ2PD Y11, K3, Y8 // 6251fe2b7ac3 VCVTUQQ2PD Y27, K3, Y8 // 6211fe2b7ac3 VCVTUQQ2PD Y17, K3, Y8 // 6231fe2b7ac1 VCVTUQQ2PD 99(R15)(R15*4), K3, Y8 // 6211fe2b7a84bf63000000 VCVTUQQ2PD 15(DX), K3, Y8 // 6271fe2b7a820f000000 VCVTUQQ2PD Z12, K7, Z1 // 62d1fe4f7acc VCVTUQQ2PD Z16, K7, Z1 // 62b1fe4f7ac8 VCVTUQQ2PD Z12, K7, Z3 // 62d1fe4f7adc VCVTUQQ2PD Z16, K7, Z3 // 62b1fe4f7ad8 VCVTUQQ2PD Z14, K4, Z28 // 6241fe4c7ae6 VCVTUQQ2PD Z28, K4, Z28 // 6201fe4c7ae4 VCVTUQQ2PD 15(R8)(R14*4), K4, Z28 // 6201fe4c7aa4b00f000000 VCVTUQQ2PD -7(CX)(DX*4), K4, Z28 // 6261fe4c7aa491f9ffffff VCVTUQQ2PD Z14, K4, Z13 // 6251fe4c7aee VCVTUQQ2PD Z28, K4, Z13 // 6211fe4c7aec VCVTUQQ2PD 15(R8)(R14*4), K4, Z13 // 6211fe4c7aacb00f000000 VCVTUQQ2PD -7(CX)(DX*4), K4, Z13 // 6271fe4c7aac91f9ffffff VCVTUQQ2PS Z3, K4, Y16 // 62e1ff4c7ac3 VCVTUQQ2PS Z12, K4, Y16 // 62c1ff4c7ac4 VCVTUQQ2PS Z3, K4, Y12 // 6271ff4c7ae3 VCVTUQQ2PS Z12, K4, Y12 // 6251ff4c7ae4 VCVTUQQ2PS Z3, K4, Y6 // 62f1ff4c7af3 VCVTUQQ2PS Z12, K4, Y6 // 62d1ff4c7af4 VCVTUQQ2PS Z15, K7, Y26 // 6241ff4f7ad7 VCVTUQQ2PS Z30, K7, Y26 // 6201ff4f7ad6 VCVTUQQ2PS (R8), K7, Y26 // 6241ff4f7a10 VCVTUQQ2PS 15(DX)(BX*2), K7, Y26 // 6261ff4f7a945a0f000000 VCVTUQQ2PS Z15, K7, Y3 // 62d1ff4f7adf VCVTUQQ2PS Z30, K7, Y3 // 6291ff4f7ade VCVTUQQ2PS (R8), K7, Y3 // 62d1ff4f7a18 VCVTUQQ2PS 15(DX)(BX*2), K7, Y3 // 62f1ff4f7a9c5a0f000000 VCVTUQQ2PS Z15, K7, Y8 // 6251ff4f7ac7 VCVTUQQ2PS Z30, K7, Y8 // 6211ff4f7ac6 VCVTUQQ2PS (R8), K7, Y8 // 6251ff4f7a00 VCVTUQQ2PS 15(DX)(BX*2), K7, Y8 // 6271ff4f7a845a0f000000 VCVTUQQ2PSX X14, K2, X16 // 62c1ff0a7ac6 VCVTUQQ2PSX X19, K2, X16 // 62a1ff0a7ac3 VCVTUQQ2PSX X8, K2, X16 // 62c1ff0a7ac0 VCVTUQQ2PSX -15(R14)(R15*1), K2, X16 // 6281ff0a7a843ef1ffffff VCVTUQQ2PSX -15(BX), K2, X16 // 62e1ff0a7a83f1ffffff VCVTUQQ2PSX X14, K2, X14 // 6251ff0a7af6 VCVTUQQ2PSX X19, K2, X14 // 6231ff0a7af3 VCVTUQQ2PSX X8, K2, X14 // 6251ff0a7af0 VCVTUQQ2PSX -15(R14)(R15*1), K2, X14 // 6211ff0a7ab43ef1ffffff VCVTUQQ2PSX -15(BX), K2, X14 // 6271ff0a7ab3f1ffffff VCVTUQQ2PSX X14, K2, X11 // 6251ff0a7ade VCVTUQQ2PSX X19, K2, X11 // 6231ff0a7adb VCVTUQQ2PSX X8, K2, X11 // 6251ff0a7ad8 VCVTUQQ2PSX -15(R14)(R15*1), K2, X11 // 6211ff0a7a9c3ef1ffffff VCVTUQQ2PSX -15(BX), K2, X11 // 6271ff0a7a9bf1ffffff VCVTUQQ2PSY Y28, K5, X8 // 6211ff2d7ac4 VCVTUQQ2PSY Y1, K5, X8 // 6271ff2d7ac1 VCVTUQQ2PSY Y23, K5, X8 // 6231ff2d7ac7 VCVTUQQ2PSY (CX), K5, X8 // 6271ff2d7a01 VCVTUQQ2PSY 99(R15), K5, X8 // 6251ff2d7a8763000000 VCVTUQQ2PSY Y28, K5, X26 // 6201ff2d7ad4 VCVTUQQ2PSY Y1, K5, X26 // 6261ff2d7ad1 VCVTUQQ2PSY Y23, K5, X26 // 6221ff2d7ad7 VCVTUQQ2PSY (CX), K5, X26 // 6261ff2d7a11 VCVTUQQ2PSY 99(R15), K5, X26 // 6241ff2d7a9763000000 VCVTUQQ2PSY Y28, K5, X23 // 6281ff2d7afc VCVTUQQ2PSY Y1, K5, X23 // 62e1ff2d7af9 VCVTUQQ2PSY Y23, K5, X23 // 62a1ff2d7aff VCVTUQQ2PSY (CX), K5, X23 // 62e1ff2d7a39 VCVTUQQ2PSY 99(R15), K5, X23 // 62c1ff2d7abf63000000 VEXTRACTF32X8 $0, Z12, K4, Y18 // 62337d4c1be200 VEXTRACTF32X8 $0, Z13, K4, Y18 // 62337d4c1bea00 VEXTRACTF32X8 $0, Z12, K4, Y24 // 62137d4c1be000 VEXTRACTF32X8 $0, Z13, K4, Y24 // 62137d4c1be800 VEXTRACTF32X8 $0, Z12, K4, Y9 // 62537d4c1be100 VEXTRACTF32X8 $0, Z13, K4, Y9 // 62537d4c1be900 VEXTRACTF32X8 $0, Z12, K4, 15(R8) // 62537d4c1ba00f00000000 VEXTRACTF32X8 $0, Z13, K4, 15(R8) // 62537d4c1ba80f00000000 VEXTRACTF32X8 $0, Z12, K4, (BP) // 62737d4c1b650000 VEXTRACTF32X8 $0, Z13, K4, (BP) // 62737d4c1b6d0000 VEXTRACTF64X2 $1, Y3, K4, X8 // 62d3fd2c19d801 VEXTRACTF64X2 $1, Y19, K4, X8 // 62c3fd2c19d801 VEXTRACTF64X2 $1, Y23, K4, X8 // 62c3fd2c19f801 VEXTRACTF64X2 $1, Y3, K4, X1 // 62f3fd2c19d901 VEXTRACTF64X2 $1, Y19, K4, X1 // 62e3fd2c19d901 VEXTRACTF64X2 $1, Y23, K4, X1 // 62e3fd2c19f901 VEXTRACTF64X2 $1, Y3, K4, X0 // 62f3fd2c19d801 VEXTRACTF64X2 $1, Y19, K4, X0 // 62e3fd2c19d801 VEXTRACTF64X2 $1, Y23, K4, X0 // 62e3fd2c19f801 VEXTRACTF64X2 $1, Y3, K4, -17(BP)(SI*8) // 62f3fd2c199cf5efffffff01 VEXTRACTF64X2 $1, Y19, K4, -17(BP)(SI*8) // 62e3fd2c199cf5efffffff01 VEXTRACTF64X2 $1, Y23, K4, -17(BP)(SI*8) // 62e3fd2c19bcf5efffffff01 VEXTRACTF64X2 $1, Y3, K4, (R15) // 62d3fd2c191f01 VEXTRACTF64X2 $1, Y19, K4, (R15) // 62c3fd2c191f01 VEXTRACTF64X2 $1, Y23, K4, (R15) // 62c3fd2c193f01 VEXTRACTF64X2 $0, Z21, K7, X15 // 62c3fd4f19ef00 VEXTRACTF64X2 $0, Z9, K7, X15 // 6253fd4f19cf00 VEXTRACTF64X2 $0, Z21, K7, X0 // 62e3fd4f19e800 VEXTRACTF64X2 $0, Z9, K7, X0 // 6273fd4f19c800 VEXTRACTF64X2 $0, Z21, K7, X16 // 62a3fd4f19e800 VEXTRACTF64X2 $0, Z9, K7, X16 // 6233fd4f19c800 VEXTRACTF64X2 $0, Z21, K7, 7(SI)(DI*8) // 62e3fd4f19acfe0700000000 VEXTRACTF64X2 $0, Z9, K7, 7(SI)(DI*8) // 6273fd4f198cfe0700000000 VEXTRACTF64X2 $0, Z21, K7, -15(R14) // 62c3fd4f19aef1ffffff00 VEXTRACTF64X2 $0, Z9, K7, -15(R14) // 6253fd4f198ef1ffffff00 VEXTRACTI32X8 $1, Z23, K4, Y21 // 62a37d4c3bfd01 VEXTRACTI32X8 $1, Z9, K4, Y21 // 62337d4c3bcd01 VEXTRACTI32X8 $1, Z23, K4, Y20 // 62a37d4c3bfc01 VEXTRACTI32X8 $1, Z9, K4, Y20 // 62337d4c3bcc01 VEXTRACTI32X8 $1, Z23, K4, Y6 // 62e37d4c3bfe01 VEXTRACTI32X8 $1, Z9, K4, Y6 // 62737d4c3bce01 VEXTRACTI32X8 $1, Z23, K4, -15(R14)(R15*1) // 62837d4c3bbc3ef1ffffff01 VEXTRACTI32X8 $1, Z9, K4, -15(R14)(R15*1) // 62137d4c3b8c3ef1ffffff01 VEXTRACTI32X8 $1, Z23, K4, -15(BX) // 62e37d4c3bbbf1ffffff01 VEXTRACTI32X8 $1, Z9, K4, -15(BX) // 62737d4c3b8bf1ffffff01 VEXTRACTI64X2 $0, Y31, K2, X7 // 6263fd2a39ff00 VEXTRACTI64X2 $0, Y6, K2, X7 // 62f3fd2a39f700 VEXTRACTI64X2 $0, Y11, K2, X7 // 6273fd2a39df00 VEXTRACTI64X2 $0, Y31, K2, X16 // 6223fd2a39f800 VEXTRACTI64X2 $0, Y6, K2, X16 // 62b3fd2a39f000 VEXTRACTI64X2 $0, Y11, K2, X16 // 6233fd2a39d800 VEXTRACTI64X2 $0, Y31, K2, X31 // 6203fd2a39ff00 VEXTRACTI64X2 $0, Y6, K2, X31 // 6293fd2a39f700 VEXTRACTI64X2 $0, Y11, K2, X31 // 6213fd2a39df00 VEXTRACTI64X2 $0, Y31, K2, -7(CX) // 6263fd2a39b9f9ffffff00 VEXTRACTI64X2 $0, Y6, K2, -7(CX) // 62f3fd2a39b1f9ffffff00 VEXTRACTI64X2 $0, Y11, K2, -7(CX) // 6273fd2a3999f9ffffff00 VEXTRACTI64X2 $0, Y31, K2, 15(DX)(BX*4) // 6263fd2a39bc9a0f00000000 VEXTRACTI64X2 $0, Y6, K2, 15(DX)(BX*4) // 62f3fd2a39b49a0f00000000 VEXTRACTI64X2 $0, Y11, K2, 15(DX)(BX*4) // 6273fd2a399c9a0f00000000 VEXTRACTI64X2 $2, Z27, K2, X1 // 6263fd4a39d902 VEXTRACTI64X2 $2, Z14, K2, X1 // 6273fd4a39f102 VEXTRACTI64X2 $2, Z27, K2, X7 // 6263fd4a39df02 VEXTRACTI64X2 $2, Z14, K2, X7 // 6273fd4a39f702 VEXTRACTI64X2 $2, Z27, K2, X9 // 6243fd4a39d902 VEXTRACTI64X2 $2, Z14, K2, X9 // 6253fd4a39f102 VEXTRACTI64X2 $2, Z27, K2, 99(R15)(R15*8) // 6203fd4a399cff6300000002 VEXTRACTI64X2 $2, Z14, K2, 99(R15)(R15*8) // 6213fd4a39b4ff6300000002 VEXTRACTI64X2 $2, Z27, K2, 7(AX)(CX*8) // 6263fd4a399cc80700000002 VEXTRACTI64X2 $2, Z14, K2, 7(AX)(CX*8) // 6273fd4a39b4c80700000002 VFPCLASSPDX $65, X14, K4, K1 // 62d3fd0c66ce41 VFPCLASSPDX $65, X19, K4, K1 // 62b3fd0c66cb41 VFPCLASSPDX $65, X8, K4, K1 // 62d3fd0c66c841 VFPCLASSPDX $65, (R14), K4, K1 // 62d3fd0c660e41 VFPCLASSPDX $65, -7(DI)(R8*8), K4, K1 // 62b3fd0c668cc7f9ffffff41 VFPCLASSPDX $65, X14, K4, K3 // 62d3fd0c66de41 VFPCLASSPDX $65, X19, K4, K3 // 62b3fd0c66db41 VFPCLASSPDX $65, X8, K4, K3 // 62d3fd0c66d841 VFPCLASSPDX $65, (R14), K4, K3 // 62d3fd0c661e41 VFPCLASSPDX $65, -7(DI)(R8*8), K4, K3 // 62b3fd0c669cc7f9ffffff41 VFPCLASSPDY $67, Y31, K1, K6 // 6293fd2966f743 VFPCLASSPDY $67, Y5, K1, K6 // 62f3fd2966f543 VFPCLASSPDY $67, Y0, K1, K6 // 62f3fd2966f043 VFPCLASSPDY $67, 7(SI)(DI*8), K1, K6 // 62f3fd2966b4fe0700000043 VFPCLASSPDY $67, -15(R14), K1, K6 // 62d3fd2966b6f1ffffff43 VFPCLASSPDY $67, Y31, K1, K7 // 6293fd2966ff43 VFPCLASSPDY $67, Y5, K1, K7 // 62f3fd2966fd43 VFPCLASSPDY $67, Y0, K1, K7 // 62f3fd2966f843 VFPCLASSPDY $67, 7(SI)(DI*8), K1, K7 // 62f3fd2966bcfe0700000043 VFPCLASSPDY $67, -15(R14), K1, K7 // 62d3fd2966bef1ffffff43 VFPCLASSPDZ $127, Z3, K3, K6 // 62f3fd4b66f37f VFPCLASSPDZ $127, Z27, K3, K6 // 6293fd4b66f37f VFPCLASSPDZ $127, 7(AX)(CX*4), K3, K6 // 62f3fd4b66b488070000007f VFPCLASSPDZ $127, 7(AX)(CX*1), K3, K6 // 62f3fd4b66b408070000007f VFPCLASSPDZ $127, Z3, K3, K4 // 62f3fd4b66e37f VFPCLASSPDZ $127, Z27, K3, K4 // 6293fd4b66e37f VFPCLASSPDZ $127, 7(AX)(CX*4), K3, K4 // 62f3fd4b66a488070000007f VFPCLASSPDZ $127, 7(AX)(CX*1), K3, K4 // 62f3fd4b66a408070000007f VFPCLASSPSX $0, X8, K4, K4 // 62d37d0c66e000 VFPCLASSPSX $0, X26, K4, K4 // 62937d0c66e200 VFPCLASSPSX $0, X23, K4, K4 // 62b37d0c66e700 VFPCLASSPSX $0, 99(R15)(R15*4), K4, K4 // 62937d0c66a4bf6300000000 VFPCLASSPSX $0, 15(DX), K4, K4 // 62f37d0c66a20f00000000 VFPCLASSPSX $0, X8, K4, K6 // 62d37d0c66f000 VFPCLASSPSX $0, X26, K4, K6 // 62937d0c66f200 VFPCLASSPSX $0, X23, K4, K6 // 62b37d0c66f700 VFPCLASSPSX $0, 99(R15)(R15*4), K4, K6 // 62937d0c66b4bf6300000000 VFPCLASSPSX $0, 15(DX), K4, K6 // 62f37d0c66b20f00000000 VFPCLASSPSY $97, Y5, K5, K4 // 62f37d2d66e561 VFPCLASSPSY $97, Y19, K5, K4 // 62b37d2d66e361 VFPCLASSPSY $97, Y31, K5, K4 // 62937d2d66e761 VFPCLASSPSY $97, 7(SI)(DI*1), K5, K4 // 62f37d2d66a43e0700000061 VFPCLASSPSY $97, 15(DX)(BX*8), K5, K4 // 62f37d2d66a4da0f00000061 VFPCLASSPSY $97, Y5, K5, K5 // 62f37d2d66ed61 VFPCLASSPSY $97, Y19, K5, K5 // 62b37d2d66eb61 VFPCLASSPSY $97, Y31, K5, K5 // 62937d2d66ef61 VFPCLASSPSY $97, 7(SI)(DI*1), K5, K5 // 62f37d2d66ac3e0700000061 VFPCLASSPSY $97, 15(DX)(BX*8), K5, K5 // 62f37d2d66acda0f00000061 VFPCLASSPSZ $81, Z7, K7, K2 // 62f37d4f66d751 VFPCLASSPSZ $81, Z9, K7, K2 // 62d37d4f66d151 VFPCLASSPSZ $81, (SI), K7, K2 // 62f37d4f661651 VFPCLASSPSZ $81, 7(SI)(DI*2), K7, K2 // 62f37d4f66947e0700000051 VFPCLASSPSZ $81, Z7, K7, K7 // 62f37d4f66ff51 VFPCLASSPSZ $81, Z9, K7, K7 // 62d37d4f66f951 VFPCLASSPSZ $81, (SI), K7, K7 // 62f37d4f663e51 VFPCLASSPSZ $81, 7(SI)(DI*2), K7, K7 // 62f37d4f66bc7e0700000051 VFPCLASSSD $42, X12, K7, K0 // 62d3fd0f67c42a or 62d3fd2f67c42a or 62d3fd4f67c42a VFPCLASSSD $42, X16, K7, K0 // 62b3fd0f67c02a or 62b3fd2f67c02a or 62b3fd4f67c02a VFPCLASSSD $42, X23, K7, K0 // 62b3fd0f67c72a or 62b3fd2f67c72a or 62b3fd4f67c72a VFPCLASSSD $42, (BX), K7, K0 // 62f3fd0f67032a or 62f3fd2f67032a or 62f3fd4f67032a VFPCLASSSD $42, -17(BP)(SI*1), K7, K0 // 62f3fd0f678435efffffff2a or 62f3fd2f678435efffffff2a or 62f3fd4f678435efffffff2a VFPCLASSSD $42, X12, K7, K5 // 62d3fd0f67ec2a or 62d3fd2f67ec2a or 62d3fd4f67ec2a VFPCLASSSD $42, X16, K7, K5 // 62b3fd0f67e82a or 62b3fd2f67e82a or 62b3fd4f67e82a VFPCLASSSD $42, X23, K7, K5 // 62b3fd0f67ef2a or 62b3fd2f67ef2a or 62b3fd4f67ef2a VFPCLASSSD $42, (BX), K7, K5 // 62f3fd0f672b2a or 62f3fd2f672b2a or 62f3fd4f672b2a VFPCLASSSD $42, -17(BP)(SI*1), K7, K5 // 62f3fd0f67ac35efffffff2a or 62f3fd2f67ac35efffffff2a or 62f3fd4f67ac35efffffff2a VFPCLASSSS $79, X23, K6, K6 // 62b37d0e67f74f or 62b37d2e67f74f or 62b37d4e67f74f VFPCLASSSS $79, X11, K6, K6 // 62d37d0e67f34f or 62d37d2e67f34f or 62d37d4e67f34f VFPCLASSSS $79, X31, K6, K6 // 62937d0e67f74f or 62937d2e67f74f or 62937d4e67f74f VFPCLASSSS $79, 7(SI)(DI*1), K6, K6 // 62f37d0e67b43e070000004f or 62f37d2e67b43e070000004f or 62f37d4e67b43e070000004f VFPCLASSSS $79, 15(DX)(BX*8), K6, K6 // 62f37d0e67b4da0f0000004f or 62f37d2e67b4da0f0000004f or 62f37d4e67b4da0f0000004f VFPCLASSSS $79, X23, K6, K5 // 62b37d0e67ef4f or 62b37d2e67ef4f or 62b37d4e67ef4f VFPCLASSSS $79, X11, K6, K5 // 62d37d0e67eb4f or 62d37d2e67eb4f or 62d37d4e67eb4f VFPCLASSSS $79, X31, K6, K5 // 62937d0e67ef4f or 62937d2e67ef4f or 62937d4e67ef4f VFPCLASSSS $79, 7(SI)(DI*1), K6, K5 // 62f37d0e67ac3e070000004f or 62f37d2e67ac3e070000004f or 62f37d4e67ac3e070000004f VFPCLASSSS $79, 15(DX)(BX*8), K6, K5 // 62f37d0e67acda0f0000004f or 62f37d2e67acda0f0000004f or 62f37d4e67acda0f0000004f VINSERTF32X8 $1, Y12, Z0, K2, Z23 // 62c37d4a1afc01 VINSERTF32X8 $1, Y21, Z0, K2, Z23 // 62a37d4a1afd01 VINSERTF32X8 $1, Y14, Z0, K2, Z23 // 62c37d4a1afe01 VINSERTF32X8 $1, 17(SP)(BP*1), Z0, K2, Z23 // 62e37d4a1abc2c1100000001 VINSERTF32X8 $1, -7(CX)(DX*8), Z0, K2, Z23 // 62e37d4a1abcd1f9ffffff01 VINSERTF32X8 $1, Y12, Z11, K2, Z23 // 62c3254a1afc01 VINSERTF32X8 $1, Y21, Z11, K2, Z23 // 62a3254a1afd01 VINSERTF32X8 $1, Y14, Z11, K2, Z23 // 62c3254a1afe01 VINSERTF32X8 $1, 17(SP)(BP*1), Z11, K2, Z23 // 62e3254a1abc2c1100000001 VINSERTF32X8 $1, -7(CX)(DX*8), Z11, K2, Z23 // 62e3254a1abcd1f9ffffff01 VINSERTF32X8 $1, Y12, Z0, K2, Z19 // 62c37d4a1adc01 VINSERTF32X8 $1, Y21, Z0, K2, Z19 // 62a37d4a1add01 VINSERTF32X8 $1, Y14, Z0, K2, Z19 // 62c37d4a1ade01 VINSERTF32X8 $1, 17(SP)(BP*1), Z0, K2, Z19 // 62e37d4a1a9c2c1100000001 VINSERTF32X8 $1, -7(CX)(DX*8), Z0, K2, Z19 // 62e37d4a1a9cd1f9ffffff01 VINSERTF32X8 $1, Y12, Z11, K2, Z19 // 62c3254a1adc01 VINSERTF32X8 $1, Y21, Z11, K2, Z19 // 62a3254a1add01 VINSERTF32X8 $1, Y14, Z11, K2, Z19 // 62c3254a1ade01 VINSERTF32X8 $1, 17(SP)(BP*1), Z11, K2, Z19 // 62e3254a1a9c2c1100000001 VINSERTF32X8 $1, -7(CX)(DX*8), Z11, K2, Z19 // 62e3254a1a9cd1f9ffffff01 VINSERTF64X2 $0, X3, Y16, K4, Y30 // 6263fd2418f300 VINSERTF64X2 $0, X26, Y16, K4, Y30 // 6203fd2418f200 VINSERTF64X2 $0, X23, Y16, K4, Y30 // 6223fd2418f700 VINSERTF64X2 $0, 7(AX)(CX*4), Y16, K4, Y30 // 6263fd2418b4880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y16, K4, Y30 // 6263fd2418b4080700000000 VINSERTF64X2 $0, X3, Y1, K4, Y30 // 6263f52c18f300 VINSERTF64X2 $0, X26, Y1, K4, Y30 // 6203f52c18f200 VINSERTF64X2 $0, X23, Y1, K4, Y30 // 6223f52c18f700 VINSERTF64X2 $0, 7(AX)(CX*4), Y1, K4, Y30 // 6263f52c18b4880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y1, K4, Y30 // 6263f52c18b4080700000000 VINSERTF64X2 $0, X3, Y30, K4, Y30 // 62638d2418f300 VINSERTF64X2 $0, X26, Y30, K4, Y30 // 62038d2418f200 VINSERTF64X2 $0, X23, Y30, K4, Y30 // 62238d2418f700 VINSERTF64X2 $0, 7(AX)(CX*4), Y30, K4, Y30 // 62638d2418b4880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y30, K4, Y30 // 62638d2418b4080700000000 VINSERTF64X2 $0, X3, Y16, K4, Y26 // 6263fd2418d300 VINSERTF64X2 $0, X26, Y16, K4, Y26 // 6203fd2418d200 VINSERTF64X2 $0, X23, Y16, K4, Y26 // 6223fd2418d700 VINSERTF64X2 $0, 7(AX)(CX*4), Y16, K4, Y26 // 6263fd241894880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y16, K4, Y26 // 6263fd241894080700000000 VINSERTF64X2 $0, X3, Y1, K4, Y26 // 6263f52c18d300 VINSERTF64X2 $0, X26, Y1, K4, Y26 // 6203f52c18d200 VINSERTF64X2 $0, X23, Y1, K4, Y26 // 6223f52c18d700 VINSERTF64X2 $0, 7(AX)(CX*4), Y1, K4, Y26 // 6263f52c1894880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y1, K4, Y26 // 6263f52c1894080700000000 VINSERTF64X2 $0, X3, Y30, K4, Y26 // 62638d2418d300 VINSERTF64X2 $0, X26, Y30, K4, Y26 // 62038d2418d200 VINSERTF64X2 $0, X23, Y30, K4, Y26 // 62238d2418d700 VINSERTF64X2 $0, 7(AX)(CX*4), Y30, K4, Y26 // 62638d241894880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y30, K4, Y26 // 62638d241894080700000000 VINSERTF64X2 $0, X3, Y16, K4, Y7 // 62f3fd2418fb00 VINSERTF64X2 $0, X26, Y16, K4, Y7 // 6293fd2418fa00 VINSERTF64X2 $0, X23, Y16, K4, Y7 // 62b3fd2418ff00 VINSERTF64X2 $0, 7(AX)(CX*4), Y16, K4, Y7 // 62f3fd2418bc880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y16, K4, Y7 // 62f3fd2418bc080700000000 VINSERTF64X2 $0, X3, Y1, K4, Y7 // 62f3f52c18fb00 VINSERTF64X2 $0, X26, Y1, K4, Y7 // 6293f52c18fa00 VINSERTF64X2 $0, X23, Y1, K4, Y7 // 62b3f52c18ff00 VINSERTF64X2 $0, 7(AX)(CX*4), Y1, K4, Y7 // 62f3f52c18bc880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y1, K4, Y7 // 62f3f52c18bc080700000000 VINSERTF64X2 $0, X3, Y30, K4, Y7 // 62f38d2418fb00 VINSERTF64X2 $0, X26, Y30, K4, Y7 // 62938d2418fa00 VINSERTF64X2 $0, X23, Y30, K4, Y7 // 62b38d2418ff00 VINSERTF64X2 $0, 7(AX)(CX*4), Y30, K4, Y7 // 62f38d2418bc880700000000 VINSERTF64X2 $0, 7(AX)(CX*1), Y30, K4, Y7 // 62f38d2418bc080700000000 VINSERTF64X2 $1, X13, Z24, K1, Z0 // 62d3bd4118c501 VINSERTF64X2 $1, X28, Z24, K1, Z0 // 6293bd4118c401 VINSERTF64X2 $1, X24, Z24, K1, Z0 // 6293bd4118c001 VINSERTF64X2 $1, (SI), Z24, K1, Z0 // 62f3bd41180601 VINSERTF64X2 $1, 7(SI)(DI*2), Z24, K1, Z0 // 62f3bd4118847e0700000001 VINSERTF64X2 $1, X13, Z12, K1, Z0 // 62d39d4918c501 VINSERTF64X2 $1, X28, Z12, K1, Z0 // 62939d4918c401 VINSERTF64X2 $1, X24, Z12, K1, Z0 // 62939d4918c001 VINSERTF64X2 $1, (SI), Z12, K1, Z0 // 62f39d49180601 VINSERTF64X2 $1, 7(SI)(DI*2), Z12, K1, Z0 // 62f39d4918847e0700000001 VINSERTF64X2 $1, X13, Z24, K1, Z25 // 6243bd4118cd01 VINSERTF64X2 $1, X28, Z24, K1, Z25 // 6203bd4118cc01 VINSERTF64X2 $1, X24, Z24, K1, Z25 // 6203bd4118c801 VINSERTF64X2 $1, (SI), Z24, K1, Z25 // 6263bd41180e01 VINSERTF64X2 $1, 7(SI)(DI*2), Z24, K1, Z25 // 6263bd41188c7e0700000001 VINSERTF64X2 $1, X13, Z12, K1, Z25 // 62439d4918cd01 VINSERTF64X2 $1, X28, Z12, K1, Z25 // 62039d4918cc01 VINSERTF64X2 $1, X24, Z12, K1, Z25 // 62039d4918c801 VINSERTF64X2 $1, (SI), Z12, K1, Z25 // 62639d49180e01 VINSERTF64X2 $1, 7(SI)(DI*2), Z12, K1, Z25 // 62639d49188c7e0700000001 VINSERTI32X8 $1, Y24, Z17, K7, Z20 // 628375473ae001 VINSERTI32X8 $1, Y13, Z17, K7, Z20 // 62c375473ae501 VINSERTI32X8 $1, Y20, Z17, K7, Z20 // 62a375473ae401 VINSERTI32X8 $1, 15(R8)(R14*1), Z17, K7, Z20 // 628375473aa4300f00000001 VINSERTI32X8 $1, 15(R8)(R14*2), Z17, K7, Z20 // 628375473aa4700f00000001 VINSERTI32X8 $1, Y24, Z0, K7, Z20 // 62837d4f3ae001 VINSERTI32X8 $1, Y13, Z0, K7, Z20 // 62c37d4f3ae501 VINSERTI32X8 $1, Y20, Z0, K7, Z20 // 62a37d4f3ae401 VINSERTI32X8 $1, 15(R8)(R14*1), Z0, K7, Z20 // 62837d4f3aa4300f00000001 VINSERTI32X8 $1, 15(R8)(R14*2), Z0, K7, Z20 // 62837d4f3aa4700f00000001 VINSERTI32X8 $1, Y24, Z17, K7, Z0 // 629375473ac001 VINSERTI32X8 $1, Y13, Z17, K7, Z0 // 62d375473ac501 VINSERTI32X8 $1, Y20, Z17, K7, Z0 // 62b375473ac401 VINSERTI32X8 $1, 15(R8)(R14*1), Z17, K7, Z0 // 629375473a84300f00000001 VINSERTI32X8 $1, 15(R8)(R14*2), Z17, K7, Z0 // 629375473a84700f00000001 VINSERTI32X8 $1, Y24, Z0, K7, Z0 // 62937d4f3ac001 VINSERTI32X8 $1, Y13, Z0, K7, Z0 // 62d37d4f3ac501 VINSERTI32X8 $1, Y20, Z0, K7, Z0 // 62b37d4f3ac401 VINSERTI32X8 $1, 15(R8)(R14*1), Z0, K7, Z0 // 62937d4f3a84300f00000001 VINSERTI32X8 $1, 15(R8)(R14*2), Z0, K7, Z0 // 62937d4f3a84700f00000001 VINSERTI64X2 $0, X11, Y26, K7, Y14 // 6253ad2738f300 VINSERTI64X2 $0, X31, Y26, K7, Y14 // 6213ad2738f700 VINSERTI64X2 $0, X3, Y26, K7, Y14 // 6273ad2738f300 VINSERTI64X2 $0, 17(SP), Y26, K7, Y14 // 6273ad2738b4241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y26, K7, Y14 // 6273ad2738b4b5efffffff00 VINSERTI64X2 $0, X11, Y30, K7, Y14 // 62538d2738f300 VINSERTI64X2 $0, X31, Y30, K7, Y14 // 62138d2738f700 VINSERTI64X2 $0, X3, Y30, K7, Y14 // 62738d2738f300 VINSERTI64X2 $0, 17(SP), Y30, K7, Y14 // 62738d2738b4241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y30, K7, Y14 // 62738d2738b4b5efffffff00 VINSERTI64X2 $0, X11, Y12, K7, Y14 // 62539d2f38f300 VINSERTI64X2 $0, X31, Y12, K7, Y14 // 62139d2f38f700 VINSERTI64X2 $0, X3, Y12, K7, Y14 // 62739d2f38f300 VINSERTI64X2 $0, 17(SP), Y12, K7, Y14 // 62739d2f38b4241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y12, K7, Y14 // 62739d2f38b4b5efffffff00 VINSERTI64X2 $0, X11, Y26, K7, Y21 // 62c3ad2738eb00 VINSERTI64X2 $0, X31, Y26, K7, Y21 // 6283ad2738ef00 VINSERTI64X2 $0, X3, Y26, K7, Y21 // 62e3ad2738eb00 VINSERTI64X2 $0, 17(SP), Y26, K7, Y21 // 62e3ad2738ac241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y26, K7, Y21 // 62e3ad2738acb5efffffff00 VINSERTI64X2 $0, X11, Y30, K7, Y21 // 62c38d2738eb00 VINSERTI64X2 $0, X31, Y30, K7, Y21 // 62838d2738ef00 VINSERTI64X2 $0, X3, Y30, K7, Y21 // 62e38d2738eb00 VINSERTI64X2 $0, 17(SP), Y30, K7, Y21 // 62e38d2738ac241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y30, K7, Y21 // 62e38d2738acb5efffffff00 VINSERTI64X2 $0, X11, Y12, K7, Y21 // 62c39d2f38eb00 VINSERTI64X2 $0, X31, Y12, K7, Y21 // 62839d2f38ef00 VINSERTI64X2 $0, X3, Y12, K7, Y21 // 62e39d2f38eb00 VINSERTI64X2 $0, 17(SP), Y12, K7, Y21 // 62e39d2f38ac241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y12, K7, Y21 // 62e39d2f38acb5efffffff00 VINSERTI64X2 $0, X11, Y26, K7, Y1 // 62d3ad2738cb00 VINSERTI64X2 $0, X31, Y26, K7, Y1 // 6293ad2738cf00 VINSERTI64X2 $0, X3, Y26, K7, Y1 // 62f3ad2738cb00 VINSERTI64X2 $0, 17(SP), Y26, K7, Y1 // 62f3ad27388c241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y26, K7, Y1 // 62f3ad27388cb5efffffff00 VINSERTI64X2 $0, X11, Y30, K7, Y1 // 62d38d2738cb00 VINSERTI64X2 $0, X31, Y30, K7, Y1 // 62938d2738cf00 VINSERTI64X2 $0, X3, Y30, K7, Y1 // 62f38d2738cb00 VINSERTI64X2 $0, 17(SP), Y30, K7, Y1 // 62f38d27388c241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y30, K7, Y1 // 62f38d27388cb5efffffff00 VINSERTI64X2 $0, X11, Y12, K7, Y1 // 62d39d2f38cb00 VINSERTI64X2 $0, X31, Y12, K7, Y1 // 62939d2f38cf00 VINSERTI64X2 $0, X3, Y12, K7, Y1 // 62f39d2f38cb00 VINSERTI64X2 $0, 17(SP), Y12, K7, Y1 // 62f39d2f388c241100000000 VINSERTI64X2 $0, -17(BP)(SI*4), Y12, K7, Y1 // 62f39d2f388cb5efffffff00 VINSERTI64X2 $3, X7, Z31, K6, Z17 // 62e3854638cf03 VINSERTI64X2 $3, X0, Z31, K6, Z17 // 62e3854638c803 VINSERTI64X2 $3, 7(AX), Z31, K6, Z17 // 62e3854638880700000003 VINSERTI64X2 $3, (DI), Z31, K6, Z17 // 62e38546380f03 VINSERTI64X2 $3, X7, Z0, K6, Z17 // 62e3fd4e38cf03 VINSERTI64X2 $3, X0, Z0, K6, Z17 // 62e3fd4e38c803 VINSERTI64X2 $3, 7(AX), Z0, K6, Z17 // 62e3fd4e38880700000003 VINSERTI64X2 $3, (DI), Z0, K6, Z17 // 62e3fd4e380f03 VINSERTI64X2 $3, X7, Z31, K6, Z23 // 62e3854638ff03 VINSERTI64X2 $3, X0, Z31, K6, Z23 // 62e3854638f803 VINSERTI64X2 $3, 7(AX), Z31, K6, Z23 // 62e3854638b80700000003 VINSERTI64X2 $3, (DI), Z31, K6, Z23 // 62e38546383f03 VINSERTI64X2 $3, X7, Z0, K6, Z23 // 62e3fd4e38ff03 VINSERTI64X2 $3, X0, Z0, K6, Z23 // 62e3fd4e38f803 VINSERTI64X2 $3, 7(AX), Z0, K6, Z23 // 62e3fd4e38b80700000003 VINSERTI64X2 $3, (DI), Z0, K6, Z23 // 62e3fd4e383f03 VORPD X11, X24, K7, X23 // 62c1bd0756fb VORPD X23, X24, K7, X23 // 62a1bd0756ff VORPD X2, X24, K7, X23 // 62e1bd0756fa VORPD -17(BP)(SI*8), X24, K7, X23 // 62e1bd0756bcf5efffffff VORPD (R15), X24, K7, X23 // 62c1bd07563f VORPD X11, X14, K7, X23 // 62c18d0f56fb VORPD X23, X14, K7, X23 // 62a18d0f56ff VORPD X2, X14, K7, X23 // 62e18d0f56fa VORPD -17(BP)(SI*8), X14, K7, X23 // 62e18d0f56bcf5efffffff VORPD (R15), X14, K7, X23 // 62c18d0f563f VORPD X11, X0, K7, X23 // 62c1fd0f56fb VORPD X23, X0, K7, X23 // 62a1fd0f56ff VORPD X2, X0, K7, X23 // 62e1fd0f56fa VORPD -17(BP)(SI*8), X0, K7, X23 // 62e1fd0f56bcf5efffffff VORPD (R15), X0, K7, X23 // 62c1fd0f563f VORPD X11, X24, K7, X11 // 6251bd0756db VORPD X23, X24, K7, X11 // 6231bd0756df VORPD X2, X24, K7, X11 // 6271bd0756da VORPD -17(BP)(SI*8), X24, K7, X11 // 6271bd07569cf5efffffff VORPD (R15), X24, K7, X11 // 6251bd07561f VORPD X11, X14, K7, X11 // 62518d0f56db VORPD X23, X14, K7, X11 // 62318d0f56df VORPD X2, X14, K7, X11 // 62718d0f56da VORPD -17(BP)(SI*8), X14, K7, X11 // 62718d0f569cf5efffffff VORPD (R15), X14, K7, X11 // 62518d0f561f VORPD X11, X0, K7, X11 // 6251fd0f56db VORPD X23, X0, K7, X11 // 6231fd0f56df VORPD X2, X0, K7, X11 // 6271fd0f56da VORPD -17(BP)(SI*8), X0, K7, X11 // 6271fd0f569cf5efffffff VORPD (R15), X0, K7, X11 // 6251fd0f561f VORPD X11, X24, K7, X31 // 6241bd0756fb VORPD X23, X24, K7, X31 // 6221bd0756ff VORPD X2, X24, K7, X31 // 6261bd0756fa VORPD -17(BP)(SI*8), X24, K7, X31 // 6261bd0756bcf5efffffff VORPD (R15), X24, K7, X31 // 6241bd07563f VORPD X11, X14, K7, X31 // 62418d0f56fb VORPD X23, X14, K7, X31 // 62218d0f56ff VORPD X2, X14, K7, X31 // 62618d0f56fa VORPD -17(BP)(SI*8), X14, K7, X31 // 62618d0f56bcf5efffffff VORPD (R15), X14, K7, X31 // 62418d0f563f VORPD X11, X0, K7, X31 // 6241fd0f56fb VORPD X23, X0, K7, X31 // 6221fd0f56ff VORPD X2, X0, K7, X31 // 6261fd0f56fa VORPD -17(BP)(SI*8), X0, K7, X31 // 6261fd0f56bcf5efffffff VORPD (R15), X0, K7, X31 // 6241fd0f563f VORPD Y16, Y5, K1, Y8 // 6231d52956c0 VORPD Y9, Y5, K1, Y8 // 6251d52956c1 VORPD Y13, Y5, K1, Y8 // 6251d52956c5 VORPD 99(R15)(R15*2), Y5, K1, Y8 // 6211d52956847f63000000 VORPD -7(DI), Y5, K1, Y8 // 6271d5295687f9ffffff VORPD Y16, Y24, K1, Y8 // 6231bd2156c0 VORPD Y9, Y24, K1, Y8 // 6251bd2156c1 VORPD Y13, Y24, K1, Y8 // 6251bd2156c5 VORPD 99(R15)(R15*2), Y24, K1, Y8 // 6211bd2156847f63000000 VORPD -7(DI), Y24, K1, Y8 // 6271bd215687f9ffffff VORPD Y16, Y21, K1, Y8 // 6231d52156c0 VORPD Y9, Y21, K1, Y8 // 6251d52156c1 VORPD Y13, Y21, K1, Y8 // 6251d52156c5 VORPD 99(R15)(R15*2), Y21, K1, Y8 // 6211d52156847f63000000 VORPD -7(DI), Y21, K1, Y8 // 6271d5215687f9ffffff VORPD Y16, Y5, K1, Y11 // 6231d52956d8 VORPD Y9, Y5, K1, Y11 // 6251d52956d9 VORPD Y13, Y5, K1, Y11 // 6251d52956dd VORPD 99(R15)(R15*2), Y5, K1, Y11 // 6211d529569c7f63000000 VORPD -7(DI), Y5, K1, Y11 // 6271d529569ff9ffffff VORPD Y16, Y24, K1, Y11 // 6231bd2156d8 VORPD Y9, Y24, K1, Y11 // 6251bd2156d9 VORPD Y13, Y24, K1, Y11 // 6251bd2156dd VORPD 99(R15)(R15*2), Y24, K1, Y11 // 6211bd21569c7f63000000 VORPD -7(DI), Y24, K1, Y11 // 6271bd21569ff9ffffff VORPD Y16, Y21, K1, Y11 // 6231d52156d8 VORPD Y9, Y21, K1, Y11 // 6251d52156d9 VORPD Y13, Y21, K1, Y11 // 6251d52156dd VORPD 99(R15)(R15*2), Y21, K1, Y11 // 6211d521569c7f63000000 VORPD -7(DI), Y21, K1, Y11 // 6271d521569ff9ffffff VORPD Y16, Y5, K1, Y24 // 6221d52956c0 VORPD Y9, Y5, K1, Y24 // 6241d52956c1 VORPD Y13, Y5, K1, Y24 // 6241d52956c5 VORPD 99(R15)(R15*2), Y5, K1, Y24 // 6201d52956847f63000000 VORPD -7(DI), Y5, K1, Y24 // 6261d5295687f9ffffff VORPD Y16, Y24, K1, Y24 // 6221bd2156c0 VORPD Y9, Y24, K1, Y24 // 6241bd2156c1 VORPD Y13, Y24, K1, Y24 // 6241bd2156c5 VORPD 99(R15)(R15*2), Y24, K1, Y24 // 6201bd2156847f63000000 VORPD -7(DI), Y24, K1, Y24 // 6261bd215687f9ffffff VORPD Y16, Y21, K1, Y24 // 6221d52156c0 VORPD Y9, Y21, K1, Y24 // 6241d52156c1 VORPD Y13, Y21, K1, Y24 // 6241d52156c5 VORPD 99(R15)(R15*2), Y21, K1, Y24 // 6201d52156847f63000000 VORPD -7(DI), Y21, K1, Y24 // 6261d5215687f9ffffff VORPD Z9, Z9, K1, Z0 // 62d1b54956c1 VORPD Z25, Z9, K1, Z0 // 6291b54956c1 VORPD -7(CX), Z9, K1, Z0 // 62f1b5495681f9ffffff VORPD 15(DX)(BX*4), Z9, K1, Z0 // 62f1b54956849a0f000000 VORPD Z9, Z3, K1, Z0 // 62d1e54956c1 VORPD Z25, Z3, K1, Z0 // 6291e54956c1 VORPD -7(CX), Z3, K1, Z0 // 62f1e5495681f9ffffff VORPD 15(DX)(BX*4), Z3, K1, Z0 // 62f1e54956849a0f000000 VORPD Z9, Z9, K1, Z26 // 6241b54956d1 VORPD Z25, Z9, K1, Z26 // 6201b54956d1 VORPD -7(CX), Z9, K1, Z26 // 6261b5495691f9ffffff VORPD 15(DX)(BX*4), Z9, K1, Z26 // 6261b54956949a0f000000 VORPD Z9, Z3, K1, Z26 // 6241e54956d1 VORPD Z25, Z3, K1, Z26 // 6201e54956d1 VORPD -7(CX), Z3, K1, Z26 // 6261e5495691f9ffffff VORPD 15(DX)(BX*4), Z3, K1, Z26 // 6261e54956949a0f000000 VORPS X2, X0, K1, X20 // 62e17c0956e2 VORPS X8, X0, K1, X20 // 62c17c0956e0 VORPS X9, X0, K1, X20 // 62c17c0956e1 VORPS 7(SI)(DI*8), X0, K1, X20 // 62e17c0956a4fe07000000 VORPS -15(R14), X0, K1, X20 // 62c17c0956a6f1ffffff VORPS X2, X9, K1, X20 // 62e1340956e2 VORPS X8, X9, K1, X20 // 62c1340956e0 VORPS X9, X9, K1, X20 // 62c1340956e1 VORPS 7(SI)(DI*8), X9, K1, X20 // 62e1340956a4fe07000000 VORPS -15(R14), X9, K1, X20 // 62c1340956a6f1ffffff VORPS X2, X13, K1, X20 // 62e1140956e2 VORPS X8, X13, K1, X20 // 62c1140956e0 VORPS X9, X13, K1, X20 // 62c1140956e1 VORPS 7(SI)(DI*8), X13, K1, X20 // 62e1140956a4fe07000000 VORPS -15(R14), X13, K1, X20 // 62c1140956a6f1ffffff VORPS X2, X0, K1, X5 // 62f17c0956ea VORPS X8, X0, K1, X5 // 62d17c0956e8 VORPS X9, X0, K1, X5 // 62d17c0956e9 VORPS 7(SI)(DI*8), X0, K1, X5 // 62f17c0956acfe07000000 VORPS -15(R14), X0, K1, X5 // 62d17c0956aef1ffffff VORPS X2, X9, K1, X5 // 62f1340956ea VORPS X8, X9, K1, X5 // 62d1340956e8 VORPS X9, X9, K1, X5 // 62d1340956e9 VORPS 7(SI)(DI*8), X9, K1, X5 // 62f1340956acfe07000000 VORPS -15(R14), X9, K1, X5 // 62d1340956aef1ffffff VORPS X2, X13, K1, X5 // 62f1140956ea VORPS X8, X13, K1, X5 // 62d1140956e8 VORPS X9, X13, K1, X5 // 62d1140956e9 VORPS 7(SI)(DI*8), X13, K1, X5 // 62f1140956acfe07000000 VORPS -15(R14), X13, K1, X5 // 62d1140956aef1ffffff VORPS X2, X0, K1, X25 // 62617c0956ca VORPS X8, X0, K1, X25 // 62417c0956c8 VORPS X9, X0, K1, X25 // 62417c0956c9 VORPS 7(SI)(DI*8), X0, K1, X25 // 62617c09568cfe07000000 VORPS -15(R14), X0, K1, X25 // 62417c09568ef1ffffff VORPS X2, X9, K1, X25 // 6261340956ca VORPS X8, X9, K1, X25 // 6241340956c8 VORPS X9, X9, K1, X25 // 6241340956c9 VORPS 7(SI)(DI*8), X9, K1, X25 // 62613409568cfe07000000 VORPS -15(R14), X9, K1, X25 // 62413409568ef1ffffff VORPS X2, X13, K1, X25 // 6261140956ca VORPS X8, X13, K1, X25 // 6241140956c8 VORPS X9, X13, K1, X25 // 6241140956c9 VORPS 7(SI)(DI*8), X13, K1, X25 // 62611409568cfe07000000 VORPS -15(R14), X13, K1, X25 // 62411409568ef1ffffff VORPS Y11, Y7, K7, Y9 // 6251442f56cb VORPS Y26, Y7, K7, Y9 // 6211442f56ca VORPS Y12, Y7, K7, Y9 // 6251442f56cc VORPS -7(CX)(DX*1), Y7, K7, Y9 // 6271442f568c11f9ffffff VORPS -15(R14)(R15*4), Y7, K7, Y9 // 6211442f568cbef1ffffff VORPS Y11, Y6, K7, Y9 // 62514c2f56cb VORPS Y26, Y6, K7, Y9 // 62114c2f56ca VORPS Y12, Y6, K7, Y9 // 62514c2f56cc VORPS -7(CX)(DX*1), Y6, K7, Y9 // 62714c2f568c11f9ffffff VORPS -15(R14)(R15*4), Y6, K7, Y9 // 62114c2f568cbef1ffffff VORPS Y11, Y26, K7, Y9 // 62512c2756cb VORPS Y26, Y26, K7, Y9 // 62112c2756ca VORPS Y12, Y26, K7, Y9 // 62512c2756cc VORPS -7(CX)(DX*1), Y26, K7, Y9 // 62712c27568c11f9ffffff VORPS -15(R14)(R15*4), Y26, K7, Y9 // 62112c27568cbef1ffffff VORPS Y11, Y7, K7, Y6 // 62d1442f56f3 VORPS Y26, Y7, K7, Y6 // 6291442f56f2 VORPS Y12, Y7, K7, Y6 // 62d1442f56f4 VORPS -7(CX)(DX*1), Y7, K7, Y6 // 62f1442f56b411f9ffffff VORPS -15(R14)(R15*4), Y7, K7, Y6 // 6291442f56b4bef1ffffff VORPS Y11, Y6, K7, Y6 // 62d14c2f56f3 VORPS Y26, Y6, K7, Y6 // 62914c2f56f2 VORPS Y12, Y6, K7, Y6 // 62d14c2f56f4 VORPS -7(CX)(DX*1), Y6, K7, Y6 // 62f14c2f56b411f9ffffff VORPS -15(R14)(R15*4), Y6, K7, Y6 // 62914c2f56b4bef1ffffff VORPS Y11, Y26, K7, Y6 // 62d12c2756f3 VORPS Y26, Y26, K7, Y6 // 62912c2756f2 VORPS Y12, Y26, K7, Y6 // 62d12c2756f4 VORPS -7(CX)(DX*1), Y26, K7, Y6 // 62f12c2756b411f9ffffff VORPS -15(R14)(R15*4), Y26, K7, Y6 // 62912c2756b4bef1ffffff VORPS Y11, Y7, K7, Y3 // 62d1442f56db VORPS Y26, Y7, K7, Y3 // 6291442f56da VORPS Y12, Y7, K7, Y3 // 62d1442f56dc VORPS -7(CX)(DX*1), Y7, K7, Y3 // 62f1442f569c11f9ffffff VORPS -15(R14)(R15*4), Y7, K7, Y3 // 6291442f569cbef1ffffff VORPS Y11, Y6, K7, Y3 // 62d14c2f56db VORPS Y26, Y6, K7, Y3 // 62914c2f56da VORPS Y12, Y6, K7, Y3 // 62d14c2f56dc VORPS -7(CX)(DX*1), Y6, K7, Y3 // 62f14c2f569c11f9ffffff VORPS -15(R14)(R15*4), Y6, K7, Y3 // 62914c2f569cbef1ffffff VORPS Y11, Y26, K7, Y3 // 62d12c2756db VORPS Y26, Y26, K7, Y3 // 62912c2756da VORPS Y12, Y26, K7, Y3 // 62d12c2756dc VORPS -7(CX)(DX*1), Y26, K7, Y3 // 62f12c27569c11f9ffffff VORPS -15(R14)(R15*4), Y26, K7, Y3 // 62912c27569cbef1ffffff VORPS Z17, Z20, K2, Z9 // 62315c4256c9 VORPS Z0, Z20, K2, Z9 // 62715c4256c8 VORPS 99(R15)(R15*8), Z20, K2, Z9 // 62115c42568cff63000000 VORPS 7(AX)(CX*8), Z20, K2, Z9 // 62715c42568cc807000000 VORPS Z17, Z0, K2, Z9 // 62317c4a56c9 VORPS Z0, Z0, K2, Z9 // 62717c4a56c8 VORPS 99(R15)(R15*8), Z0, K2, Z9 // 62117c4a568cff63000000 VORPS 7(AX)(CX*8), Z0, K2, Z9 // 62717c4a568cc807000000 VORPS Z17, Z20, K2, Z28 // 62215c4256e1 VORPS Z0, Z20, K2, Z28 // 62615c4256e0 VORPS 99(R15)(R15*8), Z20, K2, Z28 // 62015c4256a4ff63000000 VORPS 7(AX)(CX*8), Z20, K2, Z28 // 62615c4256a4c807000000 VORPS Z17, Z0, K2, Z28 // 62217c4a56e1 VORPS Z0, Z0, K2, Z28 // 62617c4a56e0 VORPS 99(R15)(R15*8), Z0, K2, Z28 // 62017c4a56a4ff63000000 VORPS 7(AX)(CX*8), Z0, K2, Z28 // 62617c4a56a4c807000000 VPEXTRD $64, X22, CX // 62e37d0816f140 VPEXTRD $64, X30, CX // 62637d0816f140 VPEXTRD $64, X22, SP // 62e37d0816f440 VPEXTRD $64, X30, SP // 62637d0816f440 VPEXTRD $64, X22, 99(R15)(R15*2) // 62837d0816b47f6300000040 VPEXTRD $64, X30, 99(R15)(R15*2) // 62037d0816b47f6300000040 VPEXTRD $64, X22, -7(DI) // 62e37d0816b7f9ffffff40 VPEXTRD $64, X30, -7(DI) // 62637d0816b7f9ffffff40 VPEXTRQ $27, X30, R9 // 6243fd0816f11b VPEXTRQ $27, X30, R13 // 6243fd0816f51b VPEXTRQ $27, X30, -15(R14)(R15*1) // 6203fd0816b43ef1ffffff1b VPEXTRQ $27, X30, -15(BX) // 6263fd0816b3f1ffffff1b VPINSRD $82, R9, X22, X21 // 62c34d0022e952 VPINSRD $82, CX, X22, X21 // 62e34d0022e952 VPINSRD $82, -7(CX)(DX*1), X22, X21 // 62e34d0022ac11f9ffffff52 VPINSRD $82, -15(R14)(R15*4), X22, X21 // 62834d0022acbef1ffffff52 VPINSRD $82, R9, X7, X21 // 62c3450822e952 VPINSRD $82, CX, X7, X21 // 62e3450822e952 VPINSRD $82, -7(CX)(DX*1), X7, X21 // 62e3450822ac11f9ffffff52 VPINSRD $82, -15(R14)(R15*4), X7, X21 // 6283450822acbef1ffffff52 VPINSRD $82, R9, X19, X21 // 62c3650022e952 VPINSRD $82, CX, X19, X21 // 62e3650022e952 VPINSRD $82, -7(CX)(DX*1), X19, X21 // 62e3650022ac11f9ffffff52 VPINSRD $82, -15(R14)(R15*4), X19, X21 // 6283650022acbef1ffffff52 VPINSRD $82, R9, X22, X0 // 62d34d0022c152 VPINSRD $82, CX, X22, X0 // 62f34d0022c152 VPINSRD $82, -7(CX)(DX*1), X22, X0 // 62f34d00228411f9ffffff52 VPINSRD $82, -15(R14)(R15*4), X22, X0 // 62934d002284bef1ffffff52 VPINSRD $82, R9, X19, X0 // 62d3650022c152 VPINSRD $82, CX, X19, X0 // 62f3650022c152 VPINSRD $82, -7(CX)(DX*1), X19, X0 // 62f36500228411f9ffffff52 VPINSRD $82, -15(R14)(R15*4), X19, X0 // 629365002284bef1ffffff52 VPINSRD $82, R9, X22, X28 // 62434d0022e152 VPINSRD $82, CX, X22, X28 // 62634d0022e152 VPINSRD $82, -7(CX)(DX*1), X22, X28 // 62634d0022a411f9ffffff52 VPINSRD $82, -15(R14)(R15*4), X22, X28 // 62034d0022a4bef1ffffff52 VPINSRD $82, R9, X7, X28 // 6243450822e152 VPINSRD $82, CX, X7, X28 // 6263450822e152 VPINSRD $82, -7(CX)(DX*1), X7, X28 // 6263450822a411f9ffffff52 VPINSRD $82, -15(R14)(R15*4), X7, X28 // 6203450822a4bef1ffffff52 VPINSRD $82, R9, X19, X28 // 6243650022e152 VPINSRD $82, CX, X19, X28 // 6263650022e152 VPINSRD $82, -7(CX)(DX*1), X19, X28 // 6263650022a411f9ffffff52 VPINSRD $82, -15(R14)(R15*4), X19, X28 // 6203650022a4bef1ffffff52 VPINSRQ $126, DX, X1, X16 // 62e3f50822c27e VPINSRQ $126, BP, X1, X16 // 62e3f50822c57e VPINSRQ $126, 7(AX)(CX*4), X1, X16 // 62e3f508228488070000007e VPINSRQ $126, 7(AX)(CX*1), X1, X16 // 62e3f508228408070000007e VPINSRQ $126, DX, X7, X16 // 62e3c50822c27e VPINSRQ $126, BP, X7, X16 // 62e3c50822c57e VPINSRQ $126, 7(AX)(CX*4), X7, X16 // 62e3c508228488070000007e VPINSRQ $126, 7(AX)(CX*1), X7, X16 // 62e3c508228408070000007e VPINSRQ $126, DX, X9, X16 // 62e3b50822c27e VPINSRQ $126, BP, X9, X16 // 62e3b50822c57e VPINSRQ $126, 7(AX)(CX*4), X9, X16 // 62e3b508228488070000007e VPINSRQ $126, 7(AX)(CX*1), X9, X16 // 62e3b508228408070000007e VPINSRQ $126, DX, X1, X31 // 6263f50822fa7e VPINSRQ $126, BP, X1, X31 // 6263f50822fd7e VPINSRQ $126, 7(AX)(CX*4), X1, X31 // 6263f50822bc88070000007e VPINSRQ $126, 7(AX)(CX*1), X1, X31 // 6263f50822bc08070000007e VPINSRQ $126, DX, X7, X31 // 6263c50822fa7e VPINSRQ $126, BP, X7, X31 // 6263c50822fd7e VPINSRQ $126, 7(AX)(CX*4), X7, X31 // 6263c50822bc88070000007e VPINSRQ $126, 7(AX)(CX*1), X7, X31 // 6263c50822bc08070000007e VPINSRQ $126, DX, X9, X31 // 6263b50822fa7e VPINSRQ $126, BP, X9, X31 // 6263b50822fd7e VPINSRQ $126, 7(AX)(CX*4), X9, X31 // 6263b50822bc88070000007e VPINSRQ $126, 7(AX)(CX*1), X9, X31 // 6263b50822bc08070000007e VPMOVD2M X3, K6 // 62f27e0839f3 VPMOVD2M X26, K6 // 62927e0839f2 VPMOVD2M X23, K6 // 62b27e0839f7 VPMOVD2M X3, K7 // 62f27e0839fb VPMOVD2M X26, K7 // 62927e0839fa VPMOVD2M X23, K7 // 62b27e0839ff VPMOVD2M Y5, K6 // 62f27e2839f5 VPMOVD2M Y28, K6 // 62927e2839f4 VPMOVD2M Y7, K6 // 62f27e2839f7 VPMOVD2M Y5, K4 // 62f27e2839e5 VPMOVD2M Y28, K4 // 62927e2839e4 VPMOVD2M Y7, K4 // 62f27e2839e7 VPMOVD2M Z1, K4 // 62f27e4839e1 VPMOVD2M Z9, K4 // 62d27e4839e1 VPMOVD2M Z1, K6 // 62f27e4839f1 VPMOVD2M Z9, K6 // 62d27e4839f1 VPMOVM2D K6, X21 // 62e27e0838ee VPMOVM2D K5, X21 // 62e27e0838ed VPMOVM2D K6, X1 // 62f27e0838ce VPMOVM2D K5, X1 // 62f27e0838cd VPMOVM2D K6, X11 // 62727e0838de VPMOVM2D K5, X11 // 62727e0838dd VPMOVM2D K1, Y28 // 62627e2838e1 VPMOVM2D K5, Y28 // 62627e2838e5 VPMOVM2D K1, Y13 // 62727e2838e9 VPMOVM2D K5, Y13 // 62727e2838ed VPMOVM2D K1, Y7 // 62f27e2838f9 VPMOVM2D K5, Y7 // 62f27e2838fd VPMOVM2D K3, Z7 // 62f27e4838fb VPMOVM2D K1, Z7 // 62f27e4838f9 VPMOVM2D K3, Z21 // 62e27e4838eb VPMOVM2D K1, Z21 // 62e27e4838e9 VPMOVM2Q K5, X13 // 6272fe0838ed VPMOVM2Q K4, X13 // 6272fe0838ec VPMOVM2Q K5, X0 // 62f2fe0838c5 VPMOVM2Q K4, X0 // 62f2fe0838c4 VPMOVM2Q K5, X30 // 6262fe0838f5 VPMOVM2Q K4, X30 // 6262fe0838f4 VPMOVM2Q K7, Y2 // 62f2fe2838d7 VPMOVM2Q K6, Y2 // 62f2fe2838d6 VPMOVM2Q K7, Y21 // 62e2fe2838ef VPMOVM2Q K6, Y21 // 62e2fe2838ee VPMOVM2Q K7, Y12 // 6272fe2838e7 VPMOVM2Q K6, Y12 // 6272fe2838e6 VPMOVM2Q K4, Z16 // 62e2fe4838c4 VPMOVM2Q K6, Z16 // 62e2fe4838c6 VPMOVM2Q K4, Z25 // 6262fe4838cc VPMOVM2Q K6, Z25 // 6262fe4838ce VPMOVQ2M X14, K1 // 62d2fe0839ce VPMOVQ2M X19, K1 // 62b2fe0839cb VPMOVQ2M X8, K1 // 62d2fe0839c8 VPMOVQ2M X14, K3 // 62d2fe0839de VPMOVQ2M X19, K3 // 62b2fe0839db VPMOVQ2M X8, K3 // 62d2fe0839d8 VPMOVQ2M Y3, K6 // 62f2fe2839f3 VPMOVQ2M Y2, K6 // 62f2fe2839f2 VPMOVQ2M Y9, K6 // 62d2fe2839f1 VPMOVQ2M Y3, K7 // 62f2fe2839fb VPMOVQ2M Y2, K7 // 62f2fe2839fa VPMOVQ2M Y9, K7 // 62d2fe2839f9 VPMOVQ2M Z12, K6 // 62d2fe4839f4 VPMOVQ2M Z13, K6 // 62d2fe4839f5 VPMOVQ2M Z12, K4 // 62d2fe4839e4 VPMOVQ2M Z13, K4 // 62d2fe4839e5 VPMULLQ X13, X3, K7, X17 // 62c2e50f40cd VPMULLQ X28, X3, K7, X17 // 6282e50f40cc VPMULLQ X24, X3, K7, X17 // 6282e50f40c8 VPMULLQ 15(R8)(R14*4), X3, K7, X17 // 6282e50f408cb00f000000 VPMULLQ -7(CX)(DX*4), X3, K7, X17 // 62e2e50f408c91f9ffffff VPMULLQ X13, X26, K7, X17 // 62c2ad0740cd VPMULLQ X28, X26, K7, X17 // 6282ad0740cc VPMULLQ X24, X26, K7, X17 // 6282ad0740c8 VPMULLQ 15(R8)(R14*4), X26, K7, X17 // 6282ad07408cb00f000000 VPMULLQ -7(CX)(DX*4), X26, K7, X17 // 62e2ad07408c91f9ffffff VPMULLQ X13, X23, K7, X17 // 62c2c50740cd VPMULLQ X28, X23, K7, X17 // 6282c50740cc VPMULLQ X24, X23, K7, X17 // 6282c50740c8 VPMULLQ 15(R8)(R14*4), X23, K7, X17 // 6282c507408cb00f000000 VPMULLQ -7(CX)(DX*4), X23, K7, X17 // 62e2c507408c91f9ffffff VPMULLQ X13, X3, K7, X15 // 6252e50f40fd VPMULLQ X28, X3, K7, X15 // 6212e50f40fc VPMULLQ X24, X3, K7, X15 // 6212e50f40f8 VPMULLQ 15(R8)(R14*4), X3, K7, X15 // 6212e50f40bcb00f000000 VPMULLQ -7(CX)(DX*4), X3, K7, X15 // 6272e50f40bc91f9ffffff VPMULLQ X13, X26, K7, X15 // 6252ad0740fd VPMULLQ X28, X26, K7, X15 // 6212ad0740fc VPMULLQ X24, X26, K7, X15 // 6212ad0740f8 VPMULLQ 15(R8)(R14*4), X26, K7, X15 // 6212ad0740bcb00f000000 VPMULLQ -7(CX)(DX*4), X26, K7, X15 // 6272ad0740bc91f9ffffff VPMULLQ X13, X23, K7, X15 // 6252c50740fd VPMULLQ X28, X23, K7, X15 // 6212c50740fc VPMULLQ X24, X23, K7, X15 // 6212c50740f8 VPMULLQ 15(R8)(R14*4), X23, K7, X15 // 6212c50740bcb00f000000 VPMULLQ -7(CX)(DX*4), X23, K7, X15 // 6272c50740bc91f9ffffff VPMULLQ X13, X3, K7, X8 // 6252e50f40c5 VPMULLQ X28, X3, K7, X8 // 6212e50f40c4 VPMULLQ X24, X3, K7, X8 // 6212e50f40c0 VPMULLQ 15(R8)(R14*4), X3, K7, X8 // 6212e50f4084b00f000000 VPMULLQ -7(CX)(DX*4), X3, K7, X8 // 6272e50f408491f9ffffff VPMULLQ X13, X26, K7, X8 // 6252ad0740c5 VPMULLQ X28, X26, K7, X8 // 6212ad0740c4 VPMULLQ X24, X26, K7, X8 // 6212ad0740c0 VPMULLQ 15(R8)(R14*4), X26, K7, X8 // 6212ad074084b00f000000 VPMULLQ -7(CX)(DX*4), X26, K7, X8 // 6272ad07408491f9ffffff VPMULLQ X13, X23, K7, X8 // 6252c50740c5 VPMULLQ X28, X23, K7, X8 // 6212c50740c4 VPMULLQ X24, X23, K7, X8 // 6212c50740c0 VPMULLQ 15(R8)(R14*4), X23, K7, X8 // 6212c5074084b00f000000 VPMULLQ -7(CX)(DX*4), X23, K7, X8 // 6272c507408491f9ffffff VPMULLQ Y28, Y31, K2, Y17 // 6282852240cc VPMULLQ Y13, Y31, K2, Y17 // 62c2852240cd VPMULLQ Y7, Y31, K2, Y17 // 62e2852240cf VPMULLQ 15(DX)(BX*1), Y31, K2, Y17 // 62e28522408c1a0f000000 VPMULLQ -7(CX)(DX*2), Y31, K2, Y17 // 62e28522408c51f9ffffff VPMULLQ Y28, Y8, K2, Y17 // 6282bd2a40cc VPMULLQ Y13, Y8, K2, Y17 // 62c2bd2a40cd VPMULLQ Y7, Y8, K2, Y17 // 62e2bd2a40cf VPMULLQ 15(DX)(BX*1), Y8, K2, Y17 // 62e2bd2a408c1a0f000000 VPMULLQ -7(CX)(DX*2), Y8, K2, Y17 // 62e2bd2a408c51f9ffffff VPMULLQ Y28, Y1, K2, Y17 // 6282f52a40cc VPMULLQ Y13, Y1, K2, Y17 // 62c2f52a40cd VPMULLQ Y7, Y1, K2, Y17 // 62e2f52a40cf VPMULLQ 15(DX)(BX*1), Y1, K2, Y17 // 62e2f52a408c1a0f000000 VPMULLQ -7(CX)(DX*2), Y1, K2, Y17 // 62e2f52a408c51f9ffffff VPMULLQ Y28, Y31, K2, Y7 // 6292852240fc VPMULLQ Y13, Y31, K2, Y7 // 62d2852240fd VPMULLQ Y7, Y31, K2, Y7 // 62f2852240ff VPMULLQ 15(DX)(BX*1), Y31, K2, Y7 // 62f2852240bc1a0f000000 VPMULLQ -7(CX)(DX*2), Y31, K2, Y7 // 62f2852240bc51f9ffffff VPMULLQ Y28, Y8, K2, Y7 // 6292bd2a40fc VPMULLQ Y13, Y8, K2, Y7 // 62d2bd2a40fd VPMULLQ Y7, Y8, K2, Y7 // 62f2bd2a40ff VPMULLQ 15(DX)(BX*1), Y8, K2, Y7 // 62f2bd2a40bc1a0f000000 VPMULLQ -7(CX)(DX*2), Y8, K2, Y7 // 62f2bd2a40bc51f9ffffff VPMULLQ Y28, Y1, K2, Y7 // 6292f52a40fc VPMULLQ Y13, Y1, K2, Y7 // 62d2f52a40fd VPMULLQ Y7, Y1, K2, Y7 // 62f2f52a40ff VPMULLQ 15(DX)(BX*1), Y1, K2, Y7 // 62f2f52a40bc1a0f000000 VPMULLQ -7(CX)(DX*2), Y1, K2, Y7 // 62f2f52a40bc51f9ffffff VPMULLQ Y28, Y31, K2, Y9 // 6212852240cc VPMULLQ Y13, Y31, K2, Y9 // 6252852240cd VPMULLQ Y7, Y31, K2, Y9 // 6272852240cf VPMULLQ 15(DX)(BX*1), Y31, K2, Y9 // 62728522408c1a0f000000 VPMULLQ -7(CX)(DX*2), Y31, K2, Y9 // 62728522408c51f9ffffff VPMULLQ Y28, Y8, K2, Y9 // 6212bd2a40cc VPMULLQ Y13, Y8, K2, Y9 // 6252bd2a40cd VPMULLQ Y7, Y8, K2, Y9 // 6272bd2a40cf VPMULLQ 15(DX)(BX*1), Y8, K2, Y9 // 6272bd2a408c1a0f000000 VPMULLQ -7(CX)(DX*2), Y8, K2, Y9 // 6272bd2a408c51f9ffffff VPMULLQ Y28, Y1, K2, Y9 // 6212f52a40cc VPMULLQ Y13, Y1, K2, Y9 // 6252f52a40cd VPMULLQ Y7, Y1, K2, Y9 // 6272f52a40cf VPMULLQ 15(DX)(BX*1), Y1, K2, Y9 // 6272f52a408c1a0f000000 VPMULLQ -7(CX)(DX*2), Y1, K2, Y9 // 6272f52a408c51f9ffffff VPMULLQ Z3, Z20, K4, Z0 // 62f2dd4440c3 VPMULLQ Z30, Z20, K4, Z0 // 6292dd4440c6 VPMULLQ 15(R8)(R14*8), Z20, K4, Z0 // 6292dd444084f00f000000 VPMULLQ -15(R14)(R15*2), Z20, K4, Z0 // 6292dd4440847ef1ffffff VPMULLQ Z3, Z28, K4, Z0 // 62f29d4440c3 VPMULLQ Z30, Z28, K4, Z0 // 62929d4440c6 VPMULLQ 15(R8)(R14*8), Z28, K4, Z0 // 62929d444084f00f000000 VPMULLQ -15(R14)(R15*2), Z28, K4, Z0 // 62929d4440847ef1ffffff VPMULLQ Z3, Z20, K4, Z6 // 62f2dd4440f3 VPMULLQ Z30, Z20, K4, Z6 // 6292dd4440f6 VPMULLQ 15(R8)(R14*8), Z20, K4, Z6 // 6292dd4440b4f00f000000 VPMULLQ -15(R14)(R15*2), Z20, K4, Z6 // 6292dd4440b47ef1ffffff VPMULLQ Z3, Z28, K4, Z6 // 62f29d4440f3 VPMULLQ Z30, Z28, K4, Z6 // 62929d4440f6 VPMULLQ 15(R8)(R14*8), Z28, K4, Z6 // 62929d4440b4f00f000000 VPMULLQ -15(R14)(R15*2), Z28, K4, Z6 // 62929d4440b47ef1ffffff VRANGEPD $11, X24, X23, K2, X12 // 6213c50250e00b VRANGEPD $11, X14, X23, K2, X12 // 6253c50250e60b VRANGEPD $11, X0, X23, K2, X12 // 6273c50250e00b VRANGEPD $11, 17(SP)(BP*8), X23, K2, X12 // 6273c50250a4ec110000000b VRANGEPD $11, 17(SP)(BP*4), X23, K2, X12 // 6273c50250a4ac110000000b VRANGEPD $11, X24, X11, K2, X12 // 6213a50a50e00b VRANGEPD $11, X14, X11, K2, X12 // 6253a50a50e60b VRANGEPD $11, X0, X11, K2, X12 // 6273a50a50e00b VRANGEPD $11, 17(SP)(BP*8), X11, K2, X12 // 6273a50a50a4ec110000000b VRANGEPD $11, 17(SP)(BP*4), X11, K2, X12 // 6273a50a50a4ac110000000b VRANGEPD $11, X24, X31, K2, X12 // 6213850250e00b VRANGEPD $11, X14, X31, K2, X12 // 6253850250e60b VRANGEPD $11, X0, X31, K2, X12 // 6273850250e00b VRANGEPD $11, 17(SP)(BP*8), X31, K2, X12 // 6273850250a4ec110000000b VRANGEPD $11, 17(SP)(BP*4), X31, K2, X12 // 6273850250a4ac110000000b VRANGEPD $11, X24, X23, K2, X16 // 6283c50250c00b VRANGEPD $11, X14, X23, K2, X16 // 62c3c50250c60b VRANGEPD $11, X0, X23, K2, X16 // 62e3c50250c00b VRANGEPD $11, 17(SP)(BP*8), X23, K2, X16 // 62e3c5025084ec110000000b VRANGEPD $11, 17(SP)(BP*4), X23, K2, X16 // 62e3c5025084ac110000000b VRANGEPD $11, X24, X11, K2, X16 // 6283a50a50c00b VRANGEPD $11, X14, X11, K2, X16 // 62c3a50a50c60b VRANGEPD $11, X0, X11, K2, X16 // 62e3a50a50c00b VRANGEPD $11, 17(SP)(BP*8), X11, K2, X16 // 62e3a50a5084ec110000000b VRANGEPD $11, 17(SP)(BP*4), X11, K2, X16 // 62e3a50a5084ac110000000b VRANGEPD $11, X24, X31, K2, X16 // 6283850250c00b VRANGEPD $11, X14, X31, K2, X16 // 62c3850250c60b VRANGEPD $11, X0, X31, K2, X16 // 62e3850250c00b VRANGEPD $11, 17(SP)(BP*8), X31, K2, X16 // 62e385025084ec110000000b VRANGEPD $11, 17(SP)(BP*4), X31, K2, X16 // 62e385025084ac110000000b VRANGEPD $11, X24, X23, K2, X23 // 6283c50250f80b VRANGEPD $11, X14, X23, K2, X23 // 62c3c50250fe0b VRANGEPD $11, X0, X23, K2, X23 // 62e3c50250f80b VRANGEPD $11, 17(SP)(BP*8), X23, K2, X23 // 62e3c50250bcec110000000b VRANGEPD $11, 17(SP)(BP*4), X23, K2, X23 // 62e3c50250bcac110000000b VRANGEPD $11, X24, X11, K2, X23 // 6283a50a50f80b VRANGEPD $11, X14, X11, K2, X23 // 62c3a50a50fe0b VRANGEPD $11, X0, X11, K2, X23 // 62e3a50a50f80b VRANGEPD $11, 17(SP)(BP*8), X11, K2, X23 // 62e3a50a50bcec110000000b VRANGEPD $11, 17(SP)(BP*4), X11, K2, X23 // 62e3a50a50bcac110000000b VRANGEPD $11, X24, X31, K2, X23 // 6283850250f80b VRANGEPD $11, X14, X31, K2, X23 // 62c3850250fe0b VRANGEPD $11, X0, X31, K2, X23 // 62e3850250f80b VRANGEPD $11, 17(SP)(BP*8), X31, K2, X23 // 62e3850250bcec110000000b VRANGEPD $11, 17(SP)(BP*4), X31, K2, X23 // 62e3850250bcac110000000b VRANGEPD $12, Y3, Y18, K1, Y15 // 6273ed2150fb0c VRANGEPD $12, Y19, Y18, K1, Y15 // 6233ed2150fb0c VRANGEPD $12, Y23, Y18, K1, Y15 // 6233ed2150ff0c VRANGEPD $12, (R8), Y18, K1, Y15 // 6253ed2150380c VRANGEPD $12, 15(DX)(BX*2), Y18, K1, Y15 // 6273ed2150bc5a0f0000000c VRANGEPD $12, Y3, Y24, K1, Y15 // 6273bd2150fb0c VRANGEPD $12, Y19, Y24, K1, Y15 // 6233bd2150fb0c VRANGEPD $12, Y23, Y24, K1, Y15 // 6233bd2150ff0c VRANGEPD $12, (R8), Y24, K1, Y15 // 6253bd2150380c VRANGEPD $12, 15(DX)(BX*2), Y24, K1, Y15 // 6273bd2150bc5a0f0000000c VRANGEPD $12, Y3, Y9, K1, Y15 // 6273b52950fb0c VRANGEPD $12, Y19, Y9, K1, Y15 // 6233b52950fb0c VRANGEPD $12, Y23, Y9, K1, Y15 // 6233b52950ff0c VRANGEPD $12, (R8), Y9, K1, Y15 // 6253b52950380c VRANGEPD $12, 15(DX)(BX*2), Y9, K1, Y15 // 6273b52950bc5a0f0000000c VRANGEPD $12, Y3, Y18, K1, Y22 // 62e3ed2150f30c VRANGEPD $12, Y19, Y18, K1, Y22 // 62a3ed2150f30c VRANGEPD $12, Y23, Y18, K1, Y22 // 62a3ed2150f70c VRANGEPD $12, (R8), Y18, K1, Y22 // 62c3ed2150300c VRANGEPD $12, 15(DX)(BX*2), Y18, K1, Y22 // 62e3ed2150b45a0f0000000c VRANGEPD $12, Y3, Y24, K1, Y22 // 62e3bd2150f30c VRANGEPD $12, Y19, Y24, K1, Y22 // 62a3bd2150f30c VRANGEPD $12, Y23, Y24, K1, Y22 // 62a3bd2150f70c VRANGEPD $12, (R8), Y24, K1, Y22 // 62c3bd2150300c VRANGEPD $12, 15(DX)(BX*2), Y24, K1, Y22 // 62e3bd2150b45a0f0000000c VRANGEPD $12, Y3, Y9, K1, Y22 // 62e3b52950f30c VRANGEPD $12, Y19, Y9, K1, Y22 // 62a3b52950f30c VRANGEPD $12, Y23, Y9, K1, Y22 // 62a3b52950f70c VRANGEPD $12, (R8), Y9, K1, Y22 // 62c3b52950300c VRANGEPD $12, 15(DX)(BX*2), Y9, K1, Y22 // 62e3b52950b45a0f0000000c VRANGEPD $12, Y3, Y18, K1, Y20 // 62e3ed2150e30c VRANGEPD $12, Y19, Y18, K1, Y20 // 62a3ed2150e30c VRANGEPD $12, Y23, Y18, K1, Y20 // 62a3ed2150e70c VRANGEPD $12, (R8), Y18, K1, Y20 // 62c3ed2150200c VRANGEPD $12, 15(DX)(BX*2), Y18, K1, Y20 // 62e3ed2150a45a0f0000000c VRANGEPD $12, Y3, Y24, K1, Y20 // 62e3bd2150e30c VRANGEPD $12, Y19, Y24, K1, Y20 // 62a3bd2150e30c VRANGEPD $12, Y23, Y24, K1, Y20 // 62a3bd2150e70c VRANGEPD $12, (R8), Y24, K1, Y20 // 62c3bd2150200c VRANGEPD $12, 15(DX)(BX*2), Y24, K1, Y20 // 62e3bd2150a45a0f0000000c VRANGEPD $12, Y3, Y9, K1, Y20 // 62e3b52950e30c VRANGEPD $12, Y19, Y9, K1, Y20 // 62a3b52950e30c VRANGEPD $12, Y23, Y9, K1, Y20 // 62a3b52950e70c VRANGEPD $12, (R8), Y9, K1, Y20 // 62c3b52950200c VRANGEPD $12, 15(DX)(BX*2), Y9, K1, Y20 // 62e3b52950a45a0f0000000c VRANGEPD $13, Z21, Z12, K7, Z14 // 62339d4f50f50d VRANGEPD $13, Z9, Z12, K7, Z14 // 62539d4f50f10d VRANGEPD $13, Z21, Z13, K7, Z14 // 6233954f50f50d VRANGEPD $13, Z9, Z13, K7, Z14 // 6253954f50f10d VRANGEPD $13, Z21, Z12, K7, Z13 // 62339d4f50ed0d VRANGEPD $13, Z9, Z12, K7, Z13 // 62539d4f50e90d VRANGEPD $13, Z21, Z13, K7, Z13 // 6233954f50ed0d VRANGEPD $13, Z9, Z13, K7, Z13 // 6253954f50e90d VRANGEPD $14, Z23, Z27, K1, Z2 // 62b3a54150d70e VRANGEPD $14, Z9, Z27, K1, Z2 // 62d3a54150d10e VRANGEPD $14, (R14), Z27, K1, Z2 // 62d3a54150160e VRANGEPD $14, -7(DI)(R8*8), Z27, K1, Z2 // 62b3a5415094c7f9ffffff0e VRANGEPD $14, Z23, Z25, K1, Z2 // 62b3b54150d70e VRANGEPD $14, Z9, Z25, K1, Z2 // 62d3b54150d10e VRANGEPD $14, (R14), Z25, K1, Z2 // 62d3b54150160e VRANGEPD $14, -7(DI)(R8*8), Z25, K1, Z2 // 62b3b5415094c7f9ffffff0e VRANGEPD $14, Z23, Z27, K1, Z7 // 62b3a54150ff0e VRANGEPD $14, Z9, Z27, K1, Z7 // 62d3a54150f90e VRANGEPD $14, (R14), Z27, K1, Z7 // 62d3a541503e0e VRANGEPD $14, -7(DI)(R8*8), Z27, K1, Z7 // 62b3a54150bcc7f9ffffff0e VRANGEPD $14, Z23, Z25, K1, Z7 // 62b3b54150ff0e VRANGEPD $14, Z9, Z25, K1, Z7 // 62d3b54150f90e VRANGEPD $14, (R14), Z25, K1, Z7 // 62d3b541503e0e VRANGEPD $14, -7(DI)(R8*8), Z25, K1, Z7 // 62b3b54150bcc7f9ffffff0e VRANGEPS $15, X0, X20, K1, X11 // 62735d0150d80f VRANGEPS $15, X9, X20, K1, X11 // 62535d0150d90f VRANGEPS $15, X13, X20, K1, X11 // 62535d0150dd0f VRANGEPS $15, 7(SI)(DI*4), X20, K1, X11 // 62735d01509cbe070000000f VRANGEPS $15, -7(DI)(R8*2), X20, K1, X11 // 62335d01509c47f9ffffff0f VRANGEPS $15, X0, X5, K1, X11 // 6273550950d80f VRANGEPS $15, X9, X5, K1, X11 // 6253550950d90f VRANGEPS $15, X13, X5, K1, X11 // 6253550950dd0f VRANGEPS $15, 7(SI)(DI*4), X5, K1, X11 // 62735509509cbe070000000f VRANGEPS $15, -7(DI)(R8*2), X5, K1, X11 // 62335509509c47f9ffffff0f VRANGEPS $15, X0, X25, K1, X11 // 6273350150d80f VRANGEPS $15, X9, X25, K1, X11 // 6253350150d90f VRANGEPS $15, X13, X25, K1, X11 // 6253350150dd0f VRANGEPS $15, 7(SI)(DI*4), X25, K1, X11 // 62733501509cbe070000000f VRANGEPS $15, -7(DI)(R8*2), X25, K1, X11 // 62333501509c47f9ffffff0f VRANGEPS $15, X0, X20, K1, X23 // 62e35d0150f80f VRANGEPS $15, X9, X20, K1, X23 // 62c35d0150f90f VRANGEPS $15, X13, X20, K1, X23 // 62c35d0150fd0f VRANGEPS $15, 7(SI)(DI*4), X20, K1, X23 // 62e35d0150bcbe070000000f VRANGEPS $15, -7(DI)(R8*2), X20, K1, X23 // 62a35d0150bc47f9ffffff0f VRANGEPS $15, X0, X5, K1, X23 // 62e3550950f80f VRANGEPS $15, X9, X5, K1, X23 // 62c3550950f90f VRANGEPS $15, X13, X5, K1, X23 // 62c3550950fd0f VRANGEPS $15, 7(SI)(DI*4), X5, K1, X23 // 62e3550950bcbe070000000f VRANGEPS $15, -7(DI)(R8*2), X5, K1, X23 // 62a3550950bc47f9ffffff0f VRANGEPS $15, X0, X25, K1, X23 // 62e3350150f80f VRANGEPS $15, X9, X25, K1, X23 // 62c3350150f90f VRANGEPS $15, X13, X25, K1, X23 // 62c3350150fd0f VRANGEPS $15, 7(SI)(DI*4), X25, K1, X23 // 62e3350150bcbe070000000f VRANGEPS $15, -7(DI)(R8*2), X25, K1, X23 // 62a3350150bc47f9ffffff0f VRANGEPS $15, X0, X20, K1, X2 // 62f35d0150d00f VRANGEPS $15, X9, X20, K1, X2 // 62d35d0150d10f VRANGEPS $15, X13, X20, K1, X2 // 62d35d0150d50f VRANGEPS $15, 7(SI)(DI*4), X20, K1, X2 // 62f35d015094be070000000f VRANGEPS $15, -7(DI)(R8*2), X20, K1, X2 // 62b35d01509447f9ffffff0f VRANGEPS $15, X0, X5, K1, X2 // 62f3550950d00f VRANGEPS $15, X9, X5, K1, X2 // 62d3550950d10f VRANGEPS $15, X13, X5, K1, X2 // 62d3550950d50f VRANGEPS $15, 7(SI)(DI*4), X5, K1, X2 // 62f355095094be070000000f VRANGEPS $15, -7(DI)(R8*2), X5, K1, X2 // 62b35509509447f9ffffff0f VRANGEPS $15, X0, X25, K1, X2 // 62f3350150d00f VRANGEPS $15, X9, X25, K1, X2 // 62d3350150d10f VRANGEPS $15, X13, X25, K1, X2 // 62d3350150d50f VRANGEPS $15, 7(SI)(DI*4), X25, K1, X2 // 62f335015094be070000000f VRANGEPS $15, -7(DI)(R8*2), X25, K1, X2 // 62b33501509447f9ffffff0f VRANGEPS $0, Y21, Y5, K1, Y19 // 62a3552950dd00 VRANGEPS $0, Y20, Y5, K1, Y19 // 62a3552950dc00 VRANGEPS $0, Y6, Y5, K1, Y19 // 62e3552950de00 VRANGEPS $0, 17(SP)(BP*1), Y5, K1, Y19 // 62e35529509c2c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y5, K1, Y19 // 62e35529509cd1f9ffffff00 VRANGEPS $0, Y21, Y16, K1, Y19 // 62a37d2150dd00 VRANGEPS $0, Y20, Y16, K1, Y19 // 62a37d2150dc00 VRANGEPS $0, Y6, Y16, K1, Y19 // 62e37d2150de00 VRANGEPS $0, 17(SP)(BP*1), Y16, K1, Y19 // 62e37d21509c2c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y16, K1, Y19 // 62e37d21509cd1f9ffffff00 VRANGEPS $0, Y21, Y2, K1, Y19 // 62a36d2950dd00 VRANGEPS $0, Y20, Y2, K1, Y19 // 62a36d2950dc00 VRANGEPS $0, Y6, Y2, K1, Y19 // 62e36d2950de00 VRANGEPS $0, 17(SP)(BP*1), Y2, K1, Y19 // 62e36d29509c2c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y2, K1, Y19 // 62e36d29509cd1f9ffffff00 VRANGEPS $0, Y21, Y5, K1, Y14 // 6233552950f500 VRANGEPS $0, Y20, Y5, K1, Y14 // 6233552950f400 VRANGEPS $0, Y6, Y5, K1, Y14 // 6273552950f600 VRANGEPS $0, 17(SP)(BP*1), Y5, K1, Y14 // 6273552950b42c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y5, K1, Y14 // 6273552950b4d1f9ffffff00 VRANGEPS $0, Y21, Y16, K1, Y14 // 62337d2150f500 VRANGEPS $0, Y20, Y16, K1, Y14 // 62337d2150f400 VRANGEPS $0, Y6, Y16, K1, Y14 // 62737d2150f600 VRANGEPS $0, 17(SP)(BP*1), Y16, K1, Y14 // 62737d2150b42c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y16, K1, Y14 // 62737d2150b4d1f9ffffff00 VRANGEPS $0, Y21, Y2, K1, Y14 // 62336d2950f500 VRANGEPS $0, Y20, Y2, K1, Y14 // 62336d2950f400 VRANGEPS $0, Y6, Y2, K1, Y14 // 62736d2950f600 VRANGEPS $0, 17(SP)(BP*1), Y2, K1, Y14 // 62736d2950b42c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y2, K1, Y14 // 62736d2950b4d1f9ffffff00 VRANGEPS $0, Y21, Y5, K1, Y21 // 62a3552950ed00 VRANGEPS $0, Y20, Y5, K1, Y21 // 62a3552950ec00 VRANGEPS $0, Y6, Y5, K1, Y21 // 62e3552950ee00 VRANGEPS $0, 17(SP)(BP*1), Y5, K1, Y21 // 62e3552950ac2c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y5, K1, Y21 // 62e3552950acd1f9ffffff00 VRANGEPS $0, Y21, Y16, K1, Y21 // 62a37d2150ed00 VRANGEPS $0, Y20, Y16, K1, Y21 // 62a37d2150ec00 VRANGEPS $0, Y6, Y16, K1, Y21 // 62e37d2150ee00 VRANGEPS $0, 17(SP)(BP*1), Y16, K1, Y21 // 62e37d2150ac2c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y16, K1, Y21 // 62e37d2150acd1f9ffffff00 VRANGEPS $0, Y21, Y2, K1, Y21 // 62a36d2950ed00 VRANGEPS $0, Y20, Y2, K1, Y21 // 62a36d2950ec00 VRANGEPS $0, Y6, Y2, K1, Y21 // 62e36d2950ee00 VRANGEPS $0, 17(SP)(BP*1), Y2, K1, Y21 // 62e36d2950ac2c1100000000 VRANGEPS $0, -7(CX)(DX*8), Y2, K1, Y21 // 62e36d2950acd1f9ffffff00 VRANGEPS $1, Z14, Z3, K7, Z27 // 6243654f50de01 VRANGEPS $1, Z7, Z3, K7, Z27 // 6263654f50df01 VRANGEPS $1, Z14, Z0, K7, Z27 // 62437d4f50de01 VRANGEPS $1, Z7, Z0, K7, Z27 // 62637d4f50df01 VRANGEPS $1, Z14, Z3, K7, Z14 // 6253654f50f601 VRANGEPS $1, Z7, Z3, K7, Z14 // 6273654f50f701 VRANGEPS $1, Z14, Z0, K7, Z14 // 62537d4f50f601 VRANGEPS $1, Z7, Z0, K7, Z14 // 62737d4f50f701 VRANGEPS $2, Z1, Z22, K2, Z8 // 62734d4250c102 VRANGEPS $2, Z16, Z22, K2, Z8 // 62334d4250c002 VRANGEPS $2, 99(R15)(R15*4), Z22, K2, Z8 // 62134d425084bf6300000002 VRANGEPS $2, 15(DX), Z22, K2, Z8 // 62734d4250820f00000002 VRANGEPS $2, Z1, Z25, K2, Z8 // 6273354250c102 VRANGEPS $2, Z16, Z25, K2, Z8 // 6233354250c002 VRANGEPS $2, 99(R15)(R15*4), Z25, K2, Z8 // 621335425084bf6300000002 VRANGEPS $2, 15(DX), Z25, K2, Z8 // 6273354250820f00000002 VRANGEPS $2, Z1, Z22, K2, Z24 // 62634d4250c102 VRANGEPS $2, Z16, Z22, K2, Z24 // 62234d4250c002 VRANGEPS $2, 99(R15)(R15*4), Z22, K2, Z24 // 62034d425084bf6300000002 VRANGEPS $2, 15(DX), Z22, K2, Z24 // 62634d4250820f00000002 VRANGEPS $2, Z1, Z25, K2, Z24 // 6263354250c102 VRANGEPS $2, Z16, Z25, K2, Z24 // 6223354250c002 VRANGEPS $2, 99(R15)(R15*4), Z25, K2, Z24 // 620335425084bf6300000002 VRANGEPS $2, 15(DX), Z25, K2, Z24 // 6263354250820f00000002 VRANGESD $3, X22, X2, K4, X2 // 62b3ed0c51d603 VRANGESD $3, X5, X2, K4, X2 // 62f3ed0c51d503 VRANGESD $3, X14, X2, K4, X2 // 62d3ed0c51d603 VRANGESD $3, X22, X31, K4, X2 // 62b3850451d603 VRANGESD $3, X5, X31, K4, X2 // 62f3850451d503 VRANGESD $3, X14, X31, K4, X2 // 62d3850451d603 VRANGESD $3, X22, X11, K4, X2 // 62b3a50c51d603 VRANGESD $3, X5, X11, K4, X2 // 62f3a50c51d503 VRANGESD $3, X14, X11, K4, X2 // 62d3a50c51d603 VRANGESD $3, X22, X2, K4, X8 // 6233ed0c51c603 VRANGESD $3, X5, X2, K4, X8 // 6273ed0c51c503 VRANGESD $3, X14, X2, K4, X8 // 6253ed0c51c603 VRANGESD $3, X22, X31, K4, X8 // 6233850451c603 VRANGESD $3, X5, X31, K4, X8 // 6273850451c503 VRANGESD $3, X14, X31, K4, X8 // 6253850451c603 VRANGESD $3, X22, X11, K4, X8 // 6233a50c51c603 VRANGESD $3, X5, X11, K4, X8 // 6273a50c51c503 VRANGESD $3, X14, X11, K4, X8 // 6253a50c51c603 VRANGESD $3, X22, X2, K4, X9 // 6233ed0c51ce03 VRANGESD $3, X5, X2, K4, X9 // 6273ed0c51cd03 VRANGESD $3, X14, X2, K4, X9 // 6253ed0c51ce03 VRANGESD $3, X22, X31, K4, X9 // 6233850451ce03 VRANGESD $3, X5, X31, K4, X9 // 6273850451cd03 VRANGESD $3, X14, X31, K4, X9 // 6253850451ce03 VRANGESD $3, X22, X11, K4, X9 // 6233a50c51ce03 VRANGESD $3, X5, X11, K4, X9 // 6273a50c51cd03 VRANGESD $3, X14, X11, K4, X9 // 6253a50c51ce03 VRANGESD $4, X18, X15, K1, X0 // 62b3850951c204 or 62b3852951c204 or 62b3854951c204 VRANGESD $4, X8, X15, K1, X0 // 62d3850951c004 or 62d3852951c004 or 62d3854951c004 VRANGESD $4, X27, X15, K1, X0 // 6293850951c304 or 6293852951c304 or 6293854951c304 VRANGESD $4, 7(AX)(CX*4), X15, K1, X0 // 62f385095184880700000004 or 62f385295184880700000004 or 62f385495184880700000004 VRANGESD $4, 7(AX)(CX*1), X15, K1, X0 // 62f385095184080700000004 or 62f385295184080700000004 or 62f385495184080700000004 VRANGESD $4, X18, X11, K1, X0 // 62b3a50951c204 or 62b3a52951c204 or 62b3a54951c204 VRANGESD $4, X8, X11, K1, X0 // 62d3a50951c004 or 62d3a52951c004 or 62d3a54951c004 VRANGESD $4, X27, X11, K1, X0 // 6293a50951c304 or 6293a52951c304 or 6293a54951c304 VRANGESD $4, 7(AX)(CX*4), X11, K1, X0 // 62f3a5095184880700000004 or 62f3a5295184880700000004 or 62f3a5495184880700000004 VRANGESD $4, 7(AX)(CX*1), X11, K1, X0 // 62f3a5095184080700000004 or 62f3a5295184080700000004 or 62f3a5495184080700000004 VRANGESD $4, X18, X0, K1, X0 // 62b3fd0951c204 or 62b3fd2951c204 or 62b3fd4951c204 VRANGESD $4, X8, X0, K1, X0 // 62d3fd0951c004 or 62d3fd2951c004 or 62d3fd4951c004 VRANGESD $4, X27, X0, K1, X0 // 6293fd0951c304 or 6293fd2951c304 or 6293fd4951c304 VRANGESD $4, 7(AX)(CX*4), X0, K1, X0 // 62f3fd095184880700000004 or 62f3fd295184880700000004 or 62f3fd495184880700000004 VRANGESD $4, 7(AX)(CX*1), X0, K1, X0 // 62f3fd095184080700000004 or 62f3fd295184080700000004 or 62f3fd495184080700000004 VRANGESD $4, X18, X15, K1, X17 // 62a3850951ca04 or 62a3852951ca04 or 62a3854951ca04 VRANGESD $4, X8, X15, K1, X17 // 62c3850951c804 or 62c3852951c804 or 62c3854951c804 VRANGESD $4, X27, X15, K1, X17 // 6283850951cb04 or 6283852951cb04 or 6283854951cb04 VRANGESD $4, 7(AX)(CX*4), X15, K1, X17 // 62e38509518c880700000004 or 62e38529518c880700000004 or 62e38549518c880700000004 VRANGESD $4, 7(AX)(CX*1), X15, K1, X17 // 62e38509518c080700000004 or 62e38529518c080700000004 or 62e38549518c080700000004 VRANGESD $4, X18, X11, K1, X17 // 62a3a50951ca04 or 62a3a52951ca04 or 62a3a54951ca04 VRANGESD $4, X8, X11, K1, X17 // 62c3a50951c804 or 62c3a52951c804 or 62c3a54951c804 VRANGESD $4, X27, X11, K1, X17 // 6283a50951cb04 or 6283a52951cb04 or 6283a54951cb04 VRANGESD $4, 7(AX)(CX*4), X11, K1, X17 // 62e3a509518c880700000004 or 62e3a529518c880700000004 or 62e3a549518c880700000004 VRANGESD $4, 7(AX)(CX*1), X11, K1, X17 // 62e3a509518c080700000004 or 62e3a529518c080700000004 or 62e3a549518c080700000004 VRANGESD $4, X18, X0, K1, X17 // 62a3fd0951ca04 or 62a3fd2951ca04 or 62a3fd4951ca04 VRANGESD $4, X8, X0, K1, X17 // 62c3fd0951c804 or 62c3fd2951c804 or 62c3fd4951c804 VRANGESD $4, X27, X0, K1, X17 // 6283fd0951cb04 or 6283fd2951cb04 or 6283fd4951cb04 VRANGESD $4, 7(AX)(CX*4), X0, K1, X17 // 62e3fd09518c880700000004 or 62e3fd29518c880700000004 or 62e3fd49518c880700000004 VRANGESD $4, 7(AX)(CX*1), X0, K1, X17 // 62e3fd09518c080700000004 or 62e3fd29518c080700000004 or 62e3fd49518c080700000004 VRANGESD $4, X18, X15, K1, X7 // 62b3850951fa04 or 62b3852951fa04 or 62b3854951fa04 VRANGESD $4, X8, X15, K1, X7 // 62d3850951f804 or 62d3852951f804 or 62d3854951f804 VRANGESD $4, X27, X15, K1, X7 // 6293850951fb04 or 6293852951fb04 or 6293854951fb04 VRANGESD $4, 7(AX)(CX*4), X15, K1, X7 // 62f3850951bc880700000004 or 62f3852951bc880700000004 or 62f3854951bc880700000004 VRANGESD $4, 7(AX)(CX*1), X15, K1, X7 // 62f3850951bc080700000004 or 62f3852951bc080700000004 or 62f3854951bc080700000004 VRANGESD $4, X18, X11, K1, X7 // 62b3a50951fa04 or 62b3a52951fa04 or 62b3a54951fa04 VRANGESD $4, X8, X11, K1, X7 // 62d3a50951f804 or 62d3a52951f804 or 62d3a54951f804 VRANGESD $4, X27, X11, K1, X7 // 6293a50951fb04 or 6293a52951fb04 or 6293a54951fb04 VRANGESD $4, 7(AX)(CX*4), X11, K1, X7 // 62f3a50951bc880700000004 or 62f3a52951bc880700000004 or 62f3a54951bc880700000004 VRANGESD $4, 7(AX)(CX*1), X11, K1, X7 // 62f3a50951bc080700000004 or 62f3a52951bc080700000004 or 62f3a54951bc080700000004 VRANGESD $4, X18, X0, K1, X7 // 62b3fd0951fa04 or 62b3fd2951fa04 or 62b3fd4951fa04 VRANGESD $4, X8, X0, K1, X7 // 62d3fd0951f804 or 62d3fd2951f804 or 62d3fd4951f804 VRANGESD $4, X27, X0, K1, X7 // 6293fd0951fb04 or 6293fd2951fb04 or 6293fd4951fb04 VRANGESD $4, 7(AX)(CX*4), X0, K1, X7 // 62f3fd0951bc880700000004 or 62f3fd2951bc880700000004 or 62f3fd4951bc880700000004 VRANGESD $4, 7(AX)(CX*1), X0, K1, X7 // 62f3fd0951bc080700000004 or 62f3fd2951bc080700000004 or 62f3fd4951bc080700000004 VRANGESS $5, X7, X15, K3, X25 // 6263050b51cf05 VRANGESS $5, X13, X15, K3, X25 // 6243050b51cd05 VRANGESS $5, X8, X15, K3, X25 // 6243050b51c805 VRANGESS $5, X7, X28, K3, X25 // 62631d0351cf05 VRANGESS $5, X13, X28, K3, X25 // 62431d0351cd05 VRANGESS $5, X8, X28, K3, X25 // 62431d0351c805 VRANGESS $5, X7, X15, K3, X3 // 62f3050b51df05 VRANGESS $5, X13, X15, K3, X3 // 62d3050b51dd05 VRANGESS $5, X8, X15, K3, X3 // 62d3050b51d805 VRANGESS $5, X7, X28, K3, X3 // 62f31d0351df05 VRANGESS $5, X13, X28, K3, X3 // 62d31d0351dd05 VRANGESS $5, X8, X28, K3, X3 // 62d31d0351d805 VRANGESS $5, X7, X15, K3, X18 // 62e3050b51d705 VRANGESS $5, X13, X15, K3, X18 // 62c3050b51d505 VRANGESS $5, X8, X15, K3, X18 // 62c3050b51d005 VRANGESS $5, X7, X28, K3, X18 // 62e31d0351d705 VRANGESS $5, X13, X28, K3, X18 // 62c31d0351d505 VRANGESS $5, X8, X28, K3, X18 // 62c31d0351d005 VRANGESS $6, X6, X22, K4, X24 // 62634d0451c606 or 62634d2451c606 or 62634d4451c606 VRANGESS $6, X7, X22, K4, X24 // 62634d0451c706 or 62634d2451c706 or 62634d4451c706 VRANGESS $6, X8, X22, K4, X24 // 62434d0451c006 or 62434d2451c006 or 62434d4451c006 VRANGESS $6, 7(SI)(DI*1), X22, K4, X24 // 62634d0451843e0700000006 or 62634d2451843e0700000006 or 62634d4451843e0700000006 VRANGESS $6, 15(DX)(BX*8), X22, K4, X24 // 62634d045184da0f00000006 or 62634d245184da0f00000006 or 62634d445184da0f00000006 VRANGESS $6, X6, X1, K4, X24 // 6263750c51c606 or 6263752c51c606 or 6263754c51c606 VRANGESS $6, X7, X1, K4, X24 // 6263750c51c706 or 6263752c51c706 or 6263754c51c706 VRANGESS $6, X8, X1, K4, X24 // 6243750c51c006 or 6243752c51c006 or 6243754c51c006 VRANGESS $6, 7(SI)(DI*1), X1, K4, X24 // 6263750c51843e0700000006 or 6263752c51843e0700000006 or 6263754c51843e0700000006 VRANGESS $6, 15(DX)(BX*8), X1, K4, X24 // 6263750c5184da0f00000006 or 6263752c5184da0f00000006 or 6263754c5184da0f00000006 VRANGESS $6, X6, X11, K4, X24 // 6263250c51c606 or 6263252c51c606 or 6263254c51c606 VRANGESS $6, X7, X11, K4, X24 // 6263250c51c706 or 6263252c51c706 or 6263254c51c706 VRANGESS $6, X8, X11, K4, X24 // 6243250c51c006 or 6243252c51c006 or 6243254c51c006 VRANGESS $6, 7(SI)(DI*1), X11, K4, X24 // 6263250c51843e0700000006 or 6263252c51843e0700000006 or 6263254c51843e0700000006 VRANGESS $6, 15(DX)(BX*8), X11, K4, X24 // 6263250c5184da0f00000006 or 6263252c5184da0f00000006 or 6263254c5184da0f00000006 VRANGESS $6, X6, X22, K4, X7 // 62f34d0451fe06 or 62f34d2451fe06 or 62f34d4451fe06 VRANGESS $6, X7, X22, K4, X7 // 62f34d0451ff06 or 62f34d2451ff06 or 62f34d4451ff06 VRANGESS $6, X8, X22, K4, X7 // 62d34d0451f806 or 62d34d2451f806 or 62d34d4451f806 VRANGESS $6, 7(SI)(DI*1), X22, K4, X7 // 62f34d0451bc3e0700000006 or 62f34d2451bc3e0700000006 or 62f34d4451bc3e0700000006 VRANGESS $6, 15(DX)(BX*8), X22, K4, X7 // 62f34d0451bcda0f00000006 or 62f34d2451bcda0f00000006 or 62f34d4451bcda0f00000006 VRANGESS $6, X6, X1, K4, X7 // 62f3750c51fe06 or 62f3752c51fe06 or 62f3754c51fe06 VRANGESS $6, X7, X1, K4, X7 // 62f3750c51ff06 or 62f3752c51ff06 or 62f3754c51ff06 VRANGESS $6, X8, X1, K4, X7 // 62d3750c51f806 or 62d3752c51f806 or 62d3754c51f806 VRANGESS $6, 7(SI)(DI*1), X1, K4, X7 // 62f3750c51bc3e0700000006 or 62f3752c51bc3e0700000006 or 62f3754c51bc3e0700000006 VRANGESS $6, 15(DX)(BX*8), X1, K4, X7 // 62f3750c51bcda0f00000006 or 62f3752c51bcda0f00000006 or 62f3754c51bcda0f00000006 VRANGESS $6, X6, X11, K4, X7 // 62f3250c51fe06 or 62f3252c51fe06 or 62f3254c51fe06 VRANGESS $6, X7, X11, K4, X7 // 62f3250c51ff06 or 62f3252c51ff06 or 62f3254c51ff06 VRANGESS $6, X8, X11, K4, X7 // 62d3250c51f806 or 62d3252c51f806 or 62d3254c51f806 VRANGESS $6, 7(SI)(DI*1), X11, K4, X7 // 62f3250c51bc3e0700000006 or 62f3252c51bc3e0700000006 or 62f3254c51bc3e0700000006 VRANGESS $6, 15(DX)(BX*8), X11, K4, X7 // 62f3250c51bcda0f00000006 or 62f3252c51bcda0f00000006 or 62f3254c51bcda0f00000006 VRANGESS $6, X6, X22, K4, X0 // 62f34d0451c606 or 62f34d2451c606 or 62f34d4451c606 VRANGESS $6, X7, X22, K4, X0 // 62f34d0451c706 or 62f34d2451c706 or 62f34d4451c706 VRANGESS $6, X8, X22, K4, X0 // 62d34d0451c006 or 62d34d2451c006 or 62d34d4451c006 VRANGESS $6, 7(SI)(DI*1), X22, K4, X0 // 62f34d0451843e0700000006 or 62f34d2451843e0700000006 or 62f34d4451843e0700000006 VRANGESS $6, 15(DX)(BX*8), X22, K4, X0 // 62f34d045184da0f00000006 or 62f34d245184da0f00000006 or 62f34d445184da0f00000006 VRANGESS $6, X6, X1, K4, X0 // 62f3750c51c606 or 62f3752c51c606 or 62f3754c51c606 VRANGESS $6, X7, X1, K4, X0 // 62f3750c51c706 or 62f3752c51c706 or 62f3754c51c706 VRANGESS $6, X8, X1, K4, X0 // 62d3750c51c006 or 62d3752c51c006 or 62d3754c51c006 VRANGESS $6, 7(SI)(DI*1), X1, K4, X0 // 62f3750c51843e0700000006 or 62f3752c51843e0700000006 or 62f3754c51843e0700000006 VRANGESS $6, 15(DX)(BX*8), X1, K4, X0 // 62f3750c5184da0f00000006 or 62f3752c5184da0f00000006 or 62f3754c5184da0f00000006 VRANGESS $6, X6, X11, K4, X0 // 62f3250c51c606 or 62f3252c51c606 or 62f3254c51c606 VRANGESS $6, X7, X11, K4, X0 // 62f3250c51c706 or 62f3252c51c706 or 62f3254c51c706 VRANGESS $6, X8, X11, K4, X0 // 62d3250c51c006 or 62d3252c51c006 or 62d3254c51c006 VRANGESS $6, 7(SI)(DI*1), X11, K4, X0 // 62f3250c51843e0700000006 or 62f3252c51843e0700000006 or 62f3254c51843e0700000006 VRANGESS $6, 15(DX)(BX*8), X11, K4, X0 // 62f3250c5184da0f00000006 or 62f3252c5184da0f00000006 or 62f3254c5184da0f00000006 VREDUCEPD $126, X8, K3, X31 // 6243fd0b56f87e VREDUCEPD $126, X1, K3, X31 // 6263fd0b56f97e VREDUCEPD $126, X0, K3, X31 // 6263fd0b56f87e VREDUCEPD $126, 99(R15)(R15*1), K3, X31 // 6203fd0b56bc3f630000007e VREDUCEPD $126, (DX), K3, X31 // 6263fd0b563a7e VREDUCEPD $126, X8, K3, X16 // 62c3fd0b56c07e VREDUCEPD $126, X1, K3, X16 // 62e3fd0b56c17e VREDUCEPD $126, X0, K3, X16 // 62e3fd0b56c07e VREDUCEPD $126, 99(R15)(R15*1), K3, X16 // 6283fd0b56843f630000007e VREDUCEPD $126, (DX), K3, X16 // 62e3fd0b56027e VREDUCEPD $126, X8, K3, X7 // 62d3fd0b56f87e VREDUCEPD $126, X1, K3, X7 // 62f3fd0b56f97e VREDUCEPD $126, X0, K3, X7 // 62f3fd0b56f87e VREDUCEPD $126, 99(R15)(R15*1), K3, X7 // 6293fd0b56bc3f630000007e VREDUCEPD $126, (DX), K3, X7 // 62f3fd0b563a7e VREDUCEPD $94, Y0, K3, Y5 // 62f3fd2b56e85e VREDUCEPD $94, Y22, K3, Y5 // 62b3fd2b56ee5e VREDUCEPD $94, Y13, K3, Y5 // 62d3fd2b56ed5e VREDUCEPD $94, (R14), K3, Y5 // 62d3fd2b562e5e VREDUCEPD $94, -7(DI)(R8*8), K3, Y5 // 62b3fd2b56acc7f9ffffff5e VREDUCEPD $94, Y0, K3, Y28 // 6263fd2b56e05e VREDUCEPD $94, Y22, K3, Y28 // 6223fd2b56e65e VREDUCEPD $94, Y13, K3, Y28 // 6243fd2b56e55e VREDUCEPD $94, (R14), K3, Y28 // 6243fd2b56265e VREDUCEPD $94, -7(DI)(R8*8), K3, Y28 // 6223fd2b56a4c7f9ffffff5e VREDUCEPD $94, Y0, K3, Y7 // 62f3fd2b56f85e VREDUCEPD $94, Y22, K3, Y7 // 62b3fd2b56fe5e VREDUCEPD $94, Y13, K3, Y7 // 62d3fd2b56fd5e VREDUCEPD $94, (R14), K3, Y7 // 62d3fd2b563e5e VREDUCEPD $94, -7(DI)(R8*8), K3, Y7 // 62b3fd2b56bcc7f9ffffff5e VREDUCEPD $121, Z3, K2, Z26 // 6263fd4a56d379 VREDUCEPD $121, Z0, K2, Z26 // 6263fd4a56d079 VREDUCEPD $121, Z3, K2, Z3 // 62f3fd4a56db79 VREDUCEPD $121, Z0, K2, Z3 // 62f3fd4a56d879 VREDUCEPD $13, Z11, K1, Z21 // 62c3fd4956eb0d VREDUCEPD $13, Z25, K1, Z21 // 6283fd4956e90d VREDUCEPD $13, -17(BP), K1, Z21 // 62e3fd4956adefffffff0d VREDUCEPD $13, -15(R14)(R15*8), K1, Z21 // 6283fd4956acfef1ffffff0d VREDUCEPD $13, Z11, K1, Z13 // 6253fd4956eb0d VREDUCEPD $13, Z25, K1, Z13 // 6213fd4956e90d VREDUCEPD $13, -17(BP), K1, Z13 // 6273fd4956adefffffff0d VREDUCEPD $13, -15(R14)(R15*8), K1, Z13 // 6213fd4956acfef1ffffff0d VREDUCEPS $65, X21, K2, X15 // 62337d0a56fd41 VREDUCEPS $65, X0, K2, X15 // 62737d0a56f841 VREDUCEPS $65, X28, K2, X15 // 62137d0a56fc41 VREDUCEPS $65, -17(BP)(SI*8), K2, X15 // 62737d0a56bcf5efffffff41 VREDUCEPS $65, (R15), K2, X15 // 62537d0a563f41 VREDUCEPS $65, X21, K2, X0 // 62b37d0a56c541 VREDUCEPS $65, X0, K2, X0 // 62f37d0a56c041 VREDUCEPS $65, X28, K2, X0 // 62937d0a56c441 VREDUCEPS $65, -17(BP)(SI*8), K2, X0 // 62f37d0a5684f5efffffff41 VREDUCEPS $65, (R15), K2, X0 // 62d37d0a560741 VREDUCEPS $65, X21, K2, X16 // 62a37d0a56c541 VREDUCEPS $65, X0, K2, X16 // 62e37d0a56c041 VREDUCEPS $65, X28, K2, X16 // 62837d0a56c441 VREDUCEPS $65, -17(BP)(SI*8), K2, X16 // 62e37d0a5684f5efffffff41 VREDUCEPS $65, (R15), K2, X16 // 62c37d0a560741 VREDUCEPS $67, Y17, K1, Y12 // 62337d2956e143 VREDUCEPS $67, Y7, K1, Y12 // 62737d2956e743 VREDUCEPS $67, Y9, K1, Y12 // 62537d2956e143 VREDUCEPS $67, 99(R15)(R15*4), K1, Y12 // 62137d2956a4bf6300000043 VREDUCEPS $67, 15(DX), K1, Y12 // 62737d2956a20f00000043 VREDUCEPS $67, Y17, K1, Y1 // 62b37d2956c943 VREDUCEPS $67, Y7, K1, Y1 // 62f37d2956cf43 VREDUCEPS $67, Y9, K1, Y1 // 62d37d2956c943 VREDUCEPS $67, 99(R15)(R15*4), K1, Y1 // 62937d29568cbf6300000043 VREDUCEPS $67, 15(DX), K1, Y1 // 62f37d29568a0f00000043 VREDUCEPS $67, Y17, K1, Y14 // 62337d2956f143 VREDUCEPS $67, Y7, K1, Y14 // 62737d2956f743 VREDUCEPS $67, Y9, K1, Y14 // 62537d2956f143 VREDUCEPS $67, 99(R15)(R15*4), K1, Y14 // 62137d2956b4bf6300000043 VREDUCEPS $67, 15(DX), K1, Y14 // 62737d2956b20f00000043 VREDUCEPS $127, Z27, K7, Z3 // 62937d4f56db7f VREDUCEPS $127, Z15, K7, Z3 // 62d37d4f56df7f VREDUCEPS $127, Z27, K7, Z12 // 62137d4f56e37f VREDUCEPS $127, Z15, K7, Z12 // 62537d4f56e77f VREDUCEPS $0, Z23, K1, Z23 // 62a37d4956ff00 VREDUCEPS $0, Z6, K1, Z23 // 62e37d4956fe00 VREDUCEPS $0, 17(SP)(BP*2), K1, Z23 // 62e37d4956bc6c1100000000 VREDUCEPS $0, -7(DI)(R8*4), K1, Z23 // 62a37d4956bc87f9ffffff00 VREDUCEPS $0, Z23, K1, Z5 // 62b37d4956ef00 VREDUCEPS $0, Z6, K1, Z5 // 62f37d4956ee00 VREDUCEPS $0, 17(SP)(BP*2), K1, Z5 // 62f37d4956ac6c1100000000 VREDUCEPS $0, -7(DI)(R8*4), K1, Z5 // 62b37d4956ac87f9ffffff00 VREDUCESD $97, X1, X7, K1, X22 // 62e3c50957f161 VREDUCESD $97, X7, X7, K1, X22 // 62e3c50957f761 VREDUCESD $97, X9, X7, K1, X22 // 62c3c50957f161 VREDUCESD $97, X1, X16, K1, X22 // 62e3fd0157f161 VREDUCESD $97, X7, X16, K1, X22 // 62e3fd0157f761 VREDUCESD $97, X9, X16, K1, X22 // 62c3fd0157f161 VREDUCESD $97, X1, X31, K1, X22 // 62e3850157f161 VREDUCESD $97, X7, X31, K1, X22 // 62e3850157f761 VREDUCESD $97, X9, X31, K1, X22 // 62c3850157f161 VREDUCESD $97, X1, X7, K1, X7 // 62f3c50957f961 VREDUCESD $97, X7, X7, K1, X7 // 62f3c50957ff61 VREDUCESD $97, X9, X7, K1, X7 // 62d3c50957f961 VREDUCESD $97, X1, X16, K1, X7 // 62f3fd0157f961 VREDUCESD $97, X7, X16, K1, X7 // 62f3fd0157ff61 VREDUCESD $97, X9, X16, K1, X7 // 62d3fd0157f961 VREDUCESD $97, X1, X31, K1, X7 // 62f3850157f961 VREDUCESD $97, X7, X31, K1, X7 // 62f3850157ff61 VREDUCESD $97, X9, X31, K1, X7 // 62d3850157f961 VREDUCESD $97, X1, X7, K1, X19 // 62e3c50957d961 VREDUCESD $97, X7, X7, K1, X19 // 62e3c50957df61 VREDUCESD $97, X9, X7, K1, X19 // 62c3c50957d961 VREDUCESD $97, X1, X16, K1, X19 // 62e3fd0157d961 VREDUCESD $97, X7, X16, K1, X19 // 62e3fd0157df61 VREDUCESD $97, X9, X16, K1, X19 // 62c3fd0157d961 VREDUCESD $97, X1, X31, K1, X19 // 62e3850157d961 VREDUCESD $97, X7, X31, K1, X19 // 62e3850157df61 VREDUCESD $97, X9, X31, K1, X19 // 62c3850157d961 VREDUCESD $81, X17, X12, K1, X15 // 62339d0957f951 or 62339d2957f951 or 62339d4957f951 VREDUCESD $81, X15, X12, K1, X15 // 62539d0957ff51 or 62539d2957ff51 or 62539d4957ff51 VREDUCESD $81, X8, X12, K1, X15 // 62539d0957f851 or 62539d2957f851 or 62539d4957f851 VREDUCESD $81, 7(SI)(DI*4), X12, K1, X15 // 62739d0957bcbe0700000051 or 62739d2957bcbe0700000051 or 62739d4957bcbe0700000051 VREDUCESD $81, -7(DI)(R8*2), X12, K1, X15 // 62339d0957bc47f9ffffff51 or 62339d2957bc47f9ffffff51 or 62339d4957bc47f9ffffff51 VREDUCESD $81, X17, X14, K1, X15 // 62338d0957f951 or 62338d2957f951 or 62338d4957f951 VREDUCESD $81, X15, X14, K1, X15 // 62538d0957ff51 or 62538d2957ff51 or 62538d4957ff51 VREDUCESD $81, X8, X14, K1, X15 // 62538d0957f851 or 62538d2957f851 or 62538d4957f851 VREDUCESD $81, 7(SI)(DI*4), X14, K1, X15 // 62738d0957bcbe0700000051 or 62738d2957bcbe0700000051 or 62738d4957bcbe0700000051 VREDUCESD $81, -7(DI)(R8*2), X14, K1, X15 // 62338d0957bc47f9ffffff51 or 62338d2957bc47f9ffffff51 or 62338d4957bc47f9ffffff51 VREDUCESD $81, X17, X5, K1, X15 // 6233d50957f951 or 6233d52957f951 or 6233d54957f951 VREDUCESD $81, X15, X5, K1, X15 // 6253d50957ff51 or 6253d52957ff51 or 6253d54957ff51 VREDUCESD $81, X8, X5, K1, X15 // 6253d50957f851 or 6253d52957f851 or 6253d54957f851 VREDUCESD $81, 7(SI)(DI*4), X5, K1, X15 // 6273d50957bcbe0700000051 or 6273d52957bcbe0700000051 or 6273d54957bcbe0700000051 VREDUCESD $81, -7(DI)(R8*2), X5, K1, X15 // 6233d50957bc47f9ffffff51 or 6233d52957bc47f9ffffff51 or 6233d54957bc47f9ffffff51 VREDUCESD $81, X17, X12, K1, X12 // 62339d0957e151 or 62339d2957e151 or 62339d4957e151 VREDUCESD $81, X15, X12, K1, X12 // 62539d0957e751 or 62539d2957e751 or 62539d4957e751 VREDUCESD $81, X8, X12, K1, X12 // 62539d0957e051 or 62539d2957e051 or 62539d4957e051 VREDUCESD $81, 7(SI)(DI*4), X12, K1, X12 // 62739d0957a4be0700000051 or 62739d2957a4be0700000051 or 62739d4957a4be0700000051 VREDUCESD $81, -7(DI)(R8*2), X12, K1, X12 // 62339d0957a447f9ffffff51 or 62339d2957a447f9ffffff51 or 62339d4957a447f9ffffff51 VREDUCESD $81, X17, X14, K1, X12 // 62338d0957e151 or 62338d2957e151 or 62338d4957e151 VREDUCESD $81, X15, X14, K1, X12 // 62538d0957e751 or 62538d2957e751 or 62538d4957e751 VREDUCESD $81, X8, X14, K1, X12 // 62538d0957e051 or 62538d2957e051 or 62538d4957e051 VREDUCESD $81, 7(SI)(DI*4), X14, K1, X12 // 62738d0957a4be0700000051 or 62738d2957a4be0700000051 or 62738d4957a4be0700000051 VREDUCESD $81, -7(DI)(R8*2), X14, K1, X12 // 62338d0957a447f9ffffff51 or 62338d2957a447f9ffffff51 or 62338d4957a447f9ffffff51 VREDUCESD $81, X17, X5, K1, X12 // 6233d50957e151 or 6233d52957e151 or 6233d54957e151 VREDUCESD $81, X15, X5, K1, X12 // 6253d50957e751 or 6253d52957e751 or 6253d54957e751 VREDUCESD $81, X8, X5, K1, X12 // 6253d50957e051 or 6253d52957e051 or 6253d54957e051 VREDUCESD $81, 7(SI)(DI*4), X5, K1, X12 // 6273d50957a4be0700000051 or 6273d52957a4be0700000051 or 6273d54957a4be0700000051 VREDUCESD $81, -7(DI)(R8*2), X5, K1, X12 // 6233d50957a447f9ffffff51 or 6233d52957a447f9ffffff51 or 6233d54957a447f9ffffff51 VREDUCESD $81, X17, X12, K1, X0 // 62b39d0957c151 or 62b39d2957c151 or 62b39d4957c151 VREDUCESD $81, X15, X12, K1, X0 // 62d39d0957c751 or 62d39d2957c751 or 62d39d4957c751 VREDUCESD $81, X8, X12, K1, X0 // 62d39d0957c051 or 62d39d2957c051 or 62d39d4957c051 VREDUCESD $81, 7(SI)(DI*4), X12, K1, X0 // 62f39d095784be0700000051 or 62f39d295784be0700000051 or 62f39d495784be0700000051 VREDUCESD $81, -7(DI)(R8*2), X12, K1, X0 // 62b39d09578447f9ffffff51 or 62b39d29578447f9ffffff51 or 62b39d49578447f9ffffff51 VREDUCESD $81, X17, X14, K1, X0 // 62b38d0957c151 or 62b38d2957c151 or 62b38d4957c151 VREDUCESD $81, X15, X14, K1, X0 // 62d38d0957c751 or 62d38d2957c751 or 62d38d4957c751 VREDUCESD $81, X8, X14, K1, X0 // 62d38d0957c051 or 62d38d2957c051 or 62d38d4957c051 VREDUCESD $81, 7(SI)(DI*4), X14, K1, X0 // 62f38d095784be0700000051 or 62f38d295784be0700000051 or 62f38d495784be0700000051 VREDUCESD $81, -7(DI)(R8*2), X14, K1, X0 // 62b38d09578447f9ffffff51 or 62b38d29578447f9ffffff51 or 62b38d49578447f9ffffff51 VREDUCESD $81, X17, X5, K1, X0 // 62b3d50957c151 or 62b3d52957c151 or 62b3d54957c151 VREDUCESD $81, X15, X5, K1, X0 // 62d3d50957c751 or 62d3d52957c751 or 62d3d54957c751 VREDUCESD $81, X8, X5, K1, X0 // 62d3d50957c051 or 62d3d52957c051 or 62d3d54957c051 VREDUCESD $81, 7(SI)(DI*4), X5, K1, X0 // 62f3d5095784be0700000051 or 62f3d5295784be0700000051 or 62f3d5495784be0700000051 VREDUCESD $81, -7(DI)(R8*2), X5, K1, X0 // 62b3d509578447f9ffffff51 or 62b3d529578447f9ffffff51 or 62b3d549578447f9ffffff51 VREDUCESS $42, X9, X13, K7, X3 // 62d3150f57d92a VREDUCESS $42, X15, X13, K7, X3 // 62d3150f57df2a VREDUCESS $42, X26, X13, K7, X3 // 6293150f57da2a VREDUCESS $42, X9, X28, K7, X3 // 62d31d0757d92a VREDUCESS $42, X15, X28, K7, X3 // 62d31d0757df2a VREDUCESS $42, X26, X28, K7, X3 // 62931d0757da2a VREDUCESS $42, X9, X24, K7, X3 // 62d33d0757d92a VREDUCESS $42, X15, X24, K7, X3 // 62d33d0757df2a VREDUCESS $42, X26, X24, K7, X3 // 62933d0757da2a VREDUCESS $42, X9, X13, K7, X26 // 6243150f57d12a VREDUCESS $42, X15, X13, K7, X26 // 6243150f57d72a VREDUCESS $42, X26, X13, K7, X26 // 6203150f57d22a VREDUCESS $42, X9, X28, K7, X26 // 62431d0757d12a VREDUCESS $42, X15, X28, K7, X26 // 62431d0757d72a VREDUCESS $42, X26, X28, K7, X26 // 62031d0757d22a VREDUCESS $42, X9, X24, K7, X26 // 62433d0757d12a VREDUCESS $42, X15, X24, K7, X26 // 62433d0757d72a VREDUCESS $42, X26, X24, K7, X26 // 62033d0757d22a VREDUCESS $42, X9, X13, K7, X23 // 62c3150f57f92a VREDUCESS $42, X15, X13, K7, X23 // 62c3150f57ff2a VREDUCESS $42, X26, X13, K7, X23 // 6283150f57fa2a VREDUCESS $42, X9, X28, K7, X23 // 62c31d0757f92a VREDUCESS $42, X15, X28, K7, X23 // 62c31d0757ff2a VREDUCESS $42, X26, X28, K7, X23 // 62831d0757fa2a VREDUCESS $42, X9, X24, K7, X23 // 62c33d0757f92a VREDUCESS $42, X15, X24, K7, X23 // 62c33d0757ff2a VREDUCESS $42, X26, X24, K7, X23 // 62833d0757fa2a VREDUCESS $79, X7, X11, K2, X18 // 62e3250a57d74f or 62e3252a57d74f or 62e3254a57d74f VREDUCESS $79, X0, X11, K2, X18 // 62e3250a57d04f or 62e3252a57d04f or 62e3254a57d04f VREDUCESS $79, 99(R15)(R15*8), X11, K2, X18 // 6283250a5794ff630000004f or 6283252a5794ff630000004f or 6283254a5794ff630000004f VREDUCESS $79, 7(AX)(CX*8), X11, K2, X18 // 62e3250a5794c8070000004f or 62e3252a5794c8070000004f or 62e3254a5794c8070000004f VREDUCESS $79, X7, X31, K2, X18 // 62e3050257d74f or 62e3052257d74f or 62e3054257d74f VREDUCESS $79, X0, X31, K2, X18 // 62e3050257d04f or 62e3052257d04f or 62e3054257d04f VREDUCESS $79, 99(R15)(R15*8), X31, K2, X18 // 628305025794ff630000004f or 628305225794ff630000004f or 628305425794ff630000004f VREDUCESS $79, 7(AX)(CX*8), X31, K2, X18 // 62e305025794c8070000004f or 62e305225794c8070000004f or 62e305425794c8070000004f VREDUCESS $79, X7, X3, K2, X18 // 62e3650a57d74f or 62e3652a57d74f or 62e3654a57d74f VREDUCESS $79, X0, X3, K2, X18 // 62e3650a57d04f or 62e3652a57d04f or 62e3654a57d04f VREDUCESS $79, 99(R15)(R15*8), X3, K2, X18 // 6283650a5794ff630000004f or 6283652a5794ff630000004f or 6283654a5794ff630000004f VREDUCESS $79, 7(AX)(CX*8), X3, K2, X18 // 62e3650a5794c8070000004f or 62e3652a5794c8070000004f or 62e3654a5794c8070000004f VREDUCESS $79, X7, X11, K2, X21 // 62e3250a57ef4f or 62e3252a57ef4f or 62e3254a57ef4f VREDUCESS $79, X0, X11, K2, X21 // 62e3250a57e84f or 62e3252a57e84f or 62e3254a57e84f VREDUCESS $79, 99(R15)(R15*8), X11, K2, X21 // 6283250a57acff630000004f or 6283252a57acff630000004f or 6283254a57acff630000004f VREDUCESS $79, 7(AX)(CX*8), X11, K2, X21 // 62e3250a57acc8070000004f or 62e3252a57acc8070000004f or 62e3254a57acc8070000004f VREDUCESS $79, X7, X31, K2, X21 // 62e3050257ef4f or 62e3052257ef4f or 62e3054257ef4f VREDUCESS $79, X0, X31, K2, X21 // 62e3050257e84f or 62e3052257e84f or 62e3054257e84f VREDUCESS $79, 99(R15)(R15*8), X31, K2, X21 // 6283050257acff630000004f or 6283052257acff630000004f or 6283054257acff630000004f VREDUCESS $79, 7(AX)(CX*8), X31, K2, X21 // 62e3050257acc8070000004f or 62e3052257acc8070000004f or 62e3054257acc8070000004f VREDUCESS $79, X7, X3, K2, X21 // 62e3650a57ef4f or 62e3652a57ef4f or 62e3654a57ef4f VREDUCESS $79, X0, X3, K2, X21 // 62e3650a57e84f or 62e3652a57e84f or 62e3654a57e84f VREDUCESS $79, 99(R15)(R15*8), X3, K2, X21 // 6283650a57acff630000004f or 6283652a57acff630000004f or 6283654a57acff630000004f VREDUCESS $79, 7(AX)(CX*8), X3, K2, X21 // 62e3650a57acc8070000004f or 62e3652a57acc8070000004f or 62e3654a57acc8070000004f VREDUCESS $79, X7, X11, K2, X1 // 62f3250a57cf4f or 62f3252a57cf4f or 62f3254a57cf4f VREDUCESS $79, X0, X11, K2, X1 // 62f3250a57c84f or 62f3252a57c84f or 62f3254a57c84f VREDUCESS $79, 99(R15)(R15*8), X11, K2, X1 // 6293250a578cff630000004f or 6293252a578cff630000004f or 6293254a578cff630000004f VREDUCESS $79, 7(AX)(CX*8), X11, K2, X1 // 62f3250a578cc8070000004f or 62f3252a578cc8070000004f or 62f3254a578cc8070000004f VREDUCESS $79, X7, X31, K2, X1 // 62f3050257cf4f or 62f3052257cf4f or 62f3054257cf4f VREDUCESS $79, X0, X31, K2, X1 // 62f3050257c84f or 62f3052257c84f or 62f3054257c84f VREDUCESS $79, 99(R15)(R15*8), X31, K2, X1 // 62930502578cff630000004f or 62930522578cff630000004f or 62930542578cff630000004f VREDUCESS $79, 7(AX)(CX*8), X31, K2, X1 // 62f30502578cc8070000004f or 62f30522578cc8070000004f or 62f30542578cc8070000004f VREDUCESS $79, X7, X3, K2, X1 // 62f3650a57cf4f or 62f3652a57cf4f or 62f3654a57cf4f VREDUCESS $79, X0, X3, K2, X1 // 62f3650a57c84f or 62f3652a57c84f or 62f3654a57c84f VREDUCESS $79, 99(R15)(R15*8), X3, K2, X1 // 6293650a578cff630000004f or 6293652a578cff630000004f or 6293654a578cff630000004f VREDUCESS $79, 7(AX)(CX*8), X3, K2, X1 // 62f3650a578cc8070000004f or 62f3652a578cc8070000004f or 62f3654a578cc8070000004f VXORPD X13, X3, K5, X17 // 62c1e50d57cd VXORPD X28, X3, K5, X17 // 6281e50d57cc VXORPD X24, X3, K5, X17 // 6281e50d57c8 VXORPD -7(CX)(DX*1), X3, K5, X17 // 62e1e50d578c11f9ffffff VXORPD -15(R14)(R15*4), X3, K5, X17 // 6281e50d578cbef1ffffff VXORPD X13, X26, K5, X17 // 62c1ad0557cd VXORPD X28, X26, K5, X17 // 6281ad0557cc VXORPD X24, X26, K5, X17 // 6281ad0557c8 VXORPD -7(CX)(DX*1), X26, K5, X17 // 62e1ad05578c11f9ffffff VXORPD -15(R14)(R15*4), X26, K5, X17 // 6281ad05578cbef1ffffff VXORPD X13, X23, K5, X17 // 62c1c50557cd VXORPD X28, X23, K5, X17 // 6281c50557cc VXORPD X24, X23, K5, X17 // 6281c50557c8 VXORPD -7(CX)(DX*1), X23, K5, X17 // 62e1c505578c11f9ffffff VXORPD -15(R14)(R15*4), X23, K5, X17 // 6281c505578cbef1ffffff VXORPD X13, X3, K5, X15 // 6251e50d57fd VXORPD X28, X3, K5, X15 // 6211e50d57fc VXORPD X24, X3, K5, X15 // 6211e50d57f8 VXORPD -7(CX)(DX*1), X3, K5, X15 // 6271e50d57bc11f9ffffff VXORPD -15(R14)(R15*4), X3, K5, X15 // 6211e50d57bcbef1ffffff VXORPD X13, X26, K5, X15 // 6251ad0557fd VXORPD X28, X26, K5, X15 // 6211ad0557fc VXORPD X24, X26, K5, X15 // 6211ad0557f8 VXORPD -7(CX)(DX*1), X26, K5, X15 // 6271ad0557bc11f9ffffff VXORPD -15(R14)(R15*4), X26, K5, X15 // 6211ad0557bcbef1ffffff VXORPD X13, X23, K5, X15 // 6251c50557fd VXORPD X28, X23, K5, X15 // 6211c50557fc VXORPD X24, X23, K5, X15 // 6211c50557f8 VXORPD -7(CX)(DX*1), X23, K5, X15 // 6271c50557bc11f9ffffff VXORPD -15(R14)(R15*4), X23, K5, X15 // 6211c50557bcbef1ffffff VXORPD X13, X3, K5, X8 // 6251e50d57c5 VXORPD X28, X3, K5, X8 // 6211e50d57c4 VXORPD X24, X3, K5, X8 // 6211e50d57c0 VXORPD -7(CX)(DX*1), X3, K5, X8 // 6271e50d578411f9ffffff VXORPD -15(R14)(R15*4), X3, K5, X8 // 6211e50d5784bef1ffffff VXORPD X13, X26, K5, X8 // 6251ad0557c5 VXORPD X28, X26, K5, X8 // 6211ad0557c4 VXORPD X24, X26, K5, X8 // 6211ad0557c0 VXORPD -7(CX)(DX*1), X26, K5, X8 // 6271ad05578411f9ffffff VXORPD -15(R14)(R15*4), X26, K5, X8 // 6211ad055784bef1ffffff VXORPD X13, X23, K5, X8 // 6251c50557c5 VXORPD X28, X23, K5, X8 // 6211c50557c4 VXORPD X24, X23, K5, X8 // 6211c50557c0 VXORPD -7(CX)(DX*1), X23, K5, X8 // 6271c505578411f9ffffff VXORPD -15(R14)(R15*4), X23, K5, X8 // 6211c5055784bef1ffffff VXORPD Y5, Y20, K3, Y0 // 62f1dd2357c5 VXORPD Y28, Y20, K3, Y0 // 6291dd2357c4 VXORPD Y7, Y20, K3, Y0 // 62f1dd2357c7 VXORPD -7(CX), Y20, K3, Y0 // 62f1dd235781f9ffffff VXORPD 15(DX)(BX*4), Y20, K3, Y0 // 62f1dd2357849a0f000000 VXORPD Y5, Y12, K3, Y0 // 62f19d2b57c5 VXORPD Y28, Y12, K3, Y0 // 62919d2b57c4 VXORPD Y7, Y12, K3, Y0 // 62f19d2b57c7 VXORPD -7(CX), Y12, K3, Y0 // 62f19d2b5781f9ffffff VXORPD 15(DX)(BX*4), Y12, K3, Y0 // 62f19d2b57849a0f000000 VXORPD Y5, Y3, K3, Y0 // 62f1e52b57c5 VXORPD Y28, Y3, K3, Y0 // 6291e52b57c4 VXORPD Y7, Y3, K3, Y0 // 62f1e52b57c7 VXORPD -7(CX), Y3, K3, Y0 // 62f1e52b5781f9ffffff VXORPD 15(DX)(BX*4), Y3, K3, Y0 // 62f1e52b57849a0f000000 VXORPD Y5, Y20, K3, Y3 // 62f1dd2357dd VXORPD Y28, Y20, K3, Y3 // 6291dd2357dc VXORPD Y7, Y20, K3, Y3 // 62f1dd2357df VXORPD -7(CX), Y20, K3, Y3 // 62f1dd235799f9ffffff VXORPD 15(DX)(BX*4), Y20, K3, Y3 // 62f1dd23579c9a0f000000 VXORPD Y5, Y12, K3, Y3 // 62f19d2b57dd VXORPD Y28, Y12, K3, Y3 // 62919d2b57dc VXORPD Y7, Y12, K3, Y3 // 62f19d2b57df VXORPD -7(CX), Y12, K3, Y3 // 62f19d2b5799f9ffffff VXORPD 15(DX)(BX*4), Y12, K3, Y3 // 62f19d2b579c9a0f000000 VXORPD Y5, Y3, K3, Y3 // 62f1e52b57dd VXORPD Y28, Y3, K3, Y3 // 6291e52b57dc VXORPD Y7, Y3, K3, Y3 // 62f1e52b57df VXORPD -7(CX), Y3, K3, Y3 // 62f1e52b5799f9ffffff VXORPD 15(DX)(BX*4), Y3, K3, Y3 // 62f1e52b579c9a0f000000 VXORPD Y5, Y20, K3, Y5 // 62f1dd2357ed VXORPD Y28, Y20, K3, Y5 // 6291dd2357ec VXORPD Y7, Y20, K3, Y5 // 62f1dd2357ef VXORPD -7(CX), Y20, K3, Y5 // 62f1dd2357a9f9ffffff VXORPD 15(DX)(BX*4), Y20, K3, Y5 // 62f1dd2357ac9a0f000000 VXORPD Y5, Y12, K3, Y5 // 62f19d2b57ed VXORPD Y28, Y12, K3, Y5 // 62919d2b57ec VXORPD Y7, Y12, K3, Y5 // 62f19d2b57ef VXORPD -7(CX), Y12, K3, Y5 // 62f19d2b57a9f9ffffff VXORPD 15(DX)(BX*4), Y12, K3, Y5 // 62f19d2b57ac9a0f000000 VXORPD Y5, Y3, K3, Y5 // 62f1e52b57ed VXORPD Y28, Y3, K3, Y5 // 6291e52b57ec VXORPD Y7, Y3, K3, Y5 // 62f1e52b57ef VXORPD -7(CX), Y3, K3, Y5 // 62f1e52b57a9f9ffffff VXORPD 15(DX)(BX*4), Y3, K3, Y5 // 62f1e52b57ac9a0f000000 VXORPD Z13, Z28, K4, Z26 // 62419d4457d5 VXORPD Z21, Z28, K4, Z26 // 62219d4457d5 VXORPD 15(R8)(R14*1), Z28, K4, Z26 // 62019d445794300f000000 VXORPD 15(R8)(R14*2), Z28, K4, Z26 // 62019d445794700f000000 VXORPD Z13, Z6, K4, Z26 // 6241cd4c57d5 VXORPD Z21, Z6, K4, Z26 // 6221cd4c57d5 VXORPD 15(R8)(R14*1), Z6, K4, Z26 // 6201cd4c5794300f000000 VXORPD 15(R8)(R14*2), Z6, K4, Z26 // 6201cd4c5794700f000000 VXORPD Z13, Z28, K4, Z14 // 62519d4457f5 VXORPD Z21, Z28, K4, Z14 // 62319d4457f5 VXORPD 15(R8)(R14*1), Z28, K4, Z14 // 62119d4457b4300f000000 VXORPD 15(R8)(R14*2), Z28, K4, Z14 // 62119d4457b4700f000000 VXORPD Z13, Z6, K4, Z14 // 6251cd4c57f5 VXORPD Z21, Z6, K4, Z14 // 6231cd4c57f5 VXORPD 15(R8)(R14*1), Z6, K4, Z14 // 6211cd4c57b4300f000000 VXORPD 15(R8)(R14*2), Z6, K4, Z14 // 6211cd4c57b4700f000000 VXORPS X11, X18, K2, X9 // 62516c0257cb VXORPS X31, X18, K2, X9 // 62116c0257cf VXORPS X3, X18, K2, X9 // 62716c0257cb VXORPS 15(DX)(BX*1), X18, K2, X9 // 62716c02578c1a0f000000 VXORPS -7(CX)(DX*2), X18, K2, X9 // 62716c02578c51f9ffffff VXORPS X11, X21, K2, X9 // 6251540257cb VXORPS X31, X21, K2, X9 // 6211540257cf VXORPS X3, X21, K2, X9 // 6271540257cb VXORPS 15(DX)(BX*1), X21, K2, X9 // 62715402578c1a0f000000 VXORPS -7(CX)(DX*2), X21, K2, X9 // 62715402578c51f9ffffff VXORPS X11, X1, K2, X9 // 6251740a57cb VXORPS X31, X1, K2, X9 // 6211740a57cf VXORPS X3, X1, K2, X9 // 6271740a57cb VXORPS 15(DX)(BX*1), X1, K2, X9 // 6271740a578c1a0f000000 VXORPS -7(CX)(DX*2), X1, K2, X9 // 6271740a578c51f9ffffff VXORPS X11, X18, K2, X15 // 62516c0257fb VXORPS X31, X18, K2, X15 // 62116c0257ff VXORPS X3, X18, K2, X15 // 62716c0257fb VXORPS 15(DX)(BX*1), X18, K2, X15 // 62716c0257bc1a0f000000 VXORPS -7(CX)(DX*2), X18, K2, X15 // 62716c0257bc51f9ffffff VXORPS X11, X21, K2, X15 // 6251540257fb VXORPS X31, X21, K2, X15 // 6211540257ff VXORPS X3, X21, K2, X15 // 6271540257fb VXORPS 15(DX)(BX*1), X21, K2, X15 // 6271540257bc1a0f000000 VXORPS -7(CX)(DX*2), X21, K2, X15 // 6271540257bc51f9ffffff VXORPS X11, X1, K2, X15 // 6251740a57fb VXORPS X31, X1, K2, X15 // 6211740a57ff VXORPS X3, X1, K2, X15 // 6271740a57fb VXORPS 15(DX)(BX*1), X1, K2, X15 // 6271740a57bc1a0f000000 VXORPS -7(CX)(DX*2), X1, K2, X15 // 6271740a57bc51f9ffffff VXORPS X11, X18, K2, X26 // 62416c0257d3 VXORPS X31, X18, K2, X26 // 62016c0257d7 VXORPS X3, X18, K2, X26 // 62616c0257d3 VXORPS 15(DX)(BX*1), X18, K2, X26 // 62616c0257941a0f000000 VXORPS -7(CX)(DX*2), X18, K2, X26 // 62616c02579451f9ffffff VXORPS X11, X21, K2, X26 // 6241540257d3 VXORPS X31, X21, K2, X26 // 6201540257d7 VXORPS X3, X21, K2, X26 // 6261540257d3 VXORPS 15(DX)(BX*1), X21, K2, X26 // 6261540257941a0f000000 VXORPS -7(CX)(DX*2), X21, K2, X26 // 62615402579451f9ffffff VXORPS X11, X1, K2, X26 // 6241740a57d3 VXORPS X31, X1, K2, X26 // 6201740a57d7 VXORPS X3, X1, K2, X26 // 6261740a57d3 VXORPS 15(DX)(BX*1), X1, K2, X26 // 6261740a57941a0f000000 VXORPS -7(CX)(DX*2), X1, K2, X26 // 6261740a579451f9ffffff VXORPS Y17, Y12, K2, Y0 // 62b11c2a57c1 VXORPS Y7, Y12, K2, Y0 // 62f11c2a57c7 VXORPS Y9, Y12, K2, Y0 // 62d11c2a57c1 VXORPS 99(R15)(R15*8), Y12, K2, Y0 // 62911c2a5784ff63000000 VXORPS 7(AX)(CX*8), Y12, K2, Y0 // 62f11c2a5784c807000000 VXORPS Y17, Y1, K2, Y0 // 62b1742a57c1 VXORPS Y7, Y1, K2, Y0 // 62f1742a57c7 VXORPS Y9, Y1, K2, Y0 // 62d1742a57c1 VXORPS 99(R15)(R15*8), Y1, K2, Y0 // 6291742a5784ff63000000 VXORPS 7(AX)(CX*8), Y1, K2, Y0 // 62f1742a5784c807000000 VXORPS Y17, Y14, K2, Y0 // 62b10c2a57c1 VXORPS Y7, Y14, K2, Y0 // 62f10c2a57c7 VXORPS Y9, Y14, K2, Y0 // 62d10c2a57c1 VXORPS 99(R15)(R15*8), Y14, K2, Y0 // 62910c2a5784ff63000000 VXORPS 7(AX)(CX*8), Y14, K2, Y0 // 62f10c2a5784c807000000 VXORPS Y17, Y12, K2, Y22 // 62a11c2a57f1 VXORPS Y7, Y12, K2, Y22 // 62e11c2a57f7 VXORPS Y9, Y12, K2, Y22 // 62c11c2a57f1 VXORPS 99(R15)(R15*8), Y12, K2, Y22 // 62811c2a57b4ff63000000 VXORPS 7(AX)(CX*8), Y12, K2, Y22 // 62e11c2a57b4c807000000 VXORPS Y17, Y1, K2, Y22 // 62a1742a57f1 VXORPS Y7, Y1, K2, Y22 // 62e1742a57f7 VXORPS Y9, Y1, K2, Y22 // 62c1742a57f1 VXORPS 99(R15)(R15*8), Y1, K2, Y22 // 6281742a57b4ff63000000 VXORPS 7(AX)(CX*8), Y1, K2, Y22 // 62e1742a57b4c807000000 VXORPS Y17, Y14, K2, Y22 // 62a10c2a57f1 VXORPS Y7, Y14, K2, Y22 // 62e10c2a57f7 VXORPS Y9, Y14, K2, Y22 // 62c10c2a57f1 VXORPS 99(R15)(R15*8), Y14, K2, Y22 // 62810c2a57b4ff63000000 VXORPS 7(AX)(CX*8), Y14, K2, Y22 // 62e10c2a57b4c807000000 VXORPS Y17, Y12, K2, Y13 // 62311c2a57e9 VXORPS Y7, Y12, K2, Y13 // 62711c2a57ef VXORPS Y9, Y12, K2, Y13 // 62511c2a57e9 VXORPS 99(R15)(R15*8), Y12, K2, Y13 // 62111c2a57acff63000000 VXORPS 7(AX)(CX*8), Y12, K2, Y13 // 62711c2a57acc807000000 VXORPS Y17, Y1, K2, Y13 // 6231742a57e9 VXORPS Y7, Y1, K2, Y13 // 6271742a57ef VXORPS Y9, Y1, K2, Y13 // 6251742a57e9 VXORPS 99(R15)(R15*8), Y1, K2, Y13 // 6211742a57acff63000000 VXORPS 7(AX)(CX*8), Y1, K2, Y13 // 6271742a57acc807000000 VXORPS Y17, Y14, K2, Y13 // 62310c2a57e9 VXORPS Y7, Y14, K2, Y13 // 62710c2a57ef VXORPS Y9, Y14, K2, Y13 // 62510c2a57e9 VXORPS 99(R15)(R15*8), Y14, K2, Y13 // 62110c2a57acff63000000 VXORPS 7(AX)(CX*8), Y14, K2, Y13 // 62710c2a57acc807000000 VXORPS Z21, Z3, K3, Z26 // 6221644b57d5 VXORPS Z13, Z3, K3, Z26 // 6241644b57d5 VXORPS (R14), Z3, K3, Z26 // 6241644b5716 VXORPS -7(DI)(R8*8), Z3, K3, Z26 // 6221644b5794c7f9ffffff VXORPS Z21, Z0, K3, Z26 // 62217c4b57d5 VXORPS Z13, Z0, K3, Z26 // 62417c4b57d5 VXORPS (R14), Z0, K3, Z26 // 62417c4b5716 VXORPS -7(DI)(R8*8), Z0, K3, Z26 // 62217c4b5794c7f9ffffff VXORPS Z21, Z3, K3, Z3 // 62b1644b57dd VXORPS Z13, Z3, K3, Z3 // 62d1644b57dd VXORPS (R14), Z3, K3, Z3 // 62d1644b571e VXORPS -7(DI)(R8*8), Z3, K3, Z3 // 62b1644b579cc7f9ffffff VXORPS Z21, Z0, K3, Z3 // 62b17c4b57dd VXORPS Z13, Z0, K3, Z3 // 62d17c4b57dd VXORPS (R14), Z0, K3, Z3 // 62d17c4b571e VXORPS -7(DI)(R8*8), Z0, K3, Z3 // 62b17c4b579cc7f9ffffff RET
go/src/cmd/asm/internal/asm/testdata/avx512enc/avx512dq.s/0
{ "file_path": "go/src/cmd/asm/internal/asm/testdata/avx512enc/avx512dq.s", "repo_id": "go", "token_count": 142064 }
66
// Copyright 2019 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. #include "../../../../../runtime/textflag.h" TEXT asmtest(SB),DUPOK|NOSPLIT,$0 start: // Unprivileged ISA // 2.4: Integer Computational Instructions ADDI $2047, X5 // 9382f27f ADDI $-2048, X5 // 93820280 ADDI $2048, X5 // 9382024093820240 ADDI $-2049, X5 // 938202c09382f2bf ADDI $4094, X5 // 9382f27f9382f27f ADDI $-4096, X5 // 9382028093820280 ADDI $4095, X5 // b71f00009b8fffffb382f201 ADDI $-4097, X5 // b7ffffff9b8fffffb382f201 ADDI $2047, X5, X6 // 1383f27f ADDI $-2048, X5, X6 // 13830280 ADDI $2048, X5, X6 // 1383024013030340 ADDI $-2049, X5, X6 // 138302c01303f3bf ADDI $4094, X5, X6 // 1383f27f1303f37f ADDI $-4096, X5, X6 // 1383028013030380 ADDI $4095, X5, X6 // b71f00009b8fffff3383f201 ADDI $-4097, X5, X6 // b7ffffff9b8fffff3383f201 SLTI $55, X5, X7 // 93a37203 SLTIU $55, X5, X7 // 93b37203 ANDI $1, X5, X6 // 13f31200 ANDI $1, X5 // 93f21200 ANDI $2048, X5 // b71f00009b8f0f80b3f2f201 ORI $1, X5, X6 // 13e31200 ORI $1, X5 // 93e21200 ORI $2048, X5 // b71f00009b8f0f80b3e2f201 XORI $1, X5, X6 // 13c31200 XORI $1, X5 // 93c21200 XORI $2048, X5 // b71f00009b8f0f80b3c2f201 SLLI $1, X5, X6 // 13931200 SLLI $1, X5 // 93921200 SRLI $1, X5, X6 // 13d31200 SRLI $1, X5 // 93d21200 SRAI $1, X5, X6 // 13d31240 SRAI $1, X5 // 93d21240 ADD X6, X5, X7 // b3836200 ADD X5, X6 // 33035300 ADD $2047, X5, X6 // 1383f27f ADD $-2048, X5, X6 // 13830280 ADD $2047, X5 // 9382f27f ADD $-2048, X5 // 93820280 SLT X6, X5, X7 // b3a36200 SLT $55, X5, X7 // 93a37203 SLTU X6, X5, X7 // b3b36200 SLTU $55, X5, X7 // 93b37203 AND X6, X5, X7 // b3f36200 AND X5, X6 // 33735300 AND $1, X5, X6 // 13f31200 AND $1, X5 // 93f21200 OR X6, X5, X7 // b3e36200 OR X5, X6 // 33635300 OR $1, X5, X6 // 13e31200 OR $1, X5 // 93e21200 XOR X6, X5, X7 // b3c36200 XOR X5, X6 // 33435300 XOR $1, X5, X6 // 13c31200 XOR $1, X5 // 93c21200 AUIPC $0, X10 // 17050000 AUIPC $0, X11 // 97050000 AUIPC $1, X10 // 17150000 AUIPC $-524288, X15 // 97070080 AUIPC $524287, X10 // 17f5ff7f LUI $0, X15 // b7070000 LUI $167, X15 // b7770a00 LUI $-524288, X15 // b7070080 LUI $524287, X15 // b7f7ff7f SLL X6, X5, X7 // b3936200 SLL X5, X6 // 33135300 SLL $1, X5, X6 // 13931200 SLL $1, X5 // 93921200 SRL X6, X5, X7 // b3d36200 SRL X5, X6 // 33535300 SRL $1, X5, X6 // 13d31200 SRL $1, X5 // 93d21200 SUB X6, X5, X7 // b3836240 SUB X5, X6 // 33035340 SUB $-2047, X5, X6 // 1383f27f SUB $2048, X5, X6 // 13830280 SUB $-2047, X5 // 9382f27f SUB $2048, X5 // 93820280 SRA X6, X5, X7 // b3d36240 SRA X5, X6 // 33535340 SRA $1, X5, X6 // 13d31240 SRA $1, X5 // 93d21240 // 2.5: Control Transfer Instructions JAL X5, 2(PC) // ef028000 JALR X6, (X5) // 67830200 JALR X6, 4(X5) // 67834200 BEQ X5, X6, 2(PC) // 63846200 BNE X5, X6, 2(PC) // 63946200 BLT X5, X6, 2(PC) // 63c46200 BLTU X5, X6, 2(PC) // 63e46200 BGE X5, X6, 2(PC) // 63d46200 BGEU X5, X6, 2(PC) // 63f46200 // 2.6: Load and Store Instructions LW (X5), X6 // 03a30200 LW 4(X5), X6 // 03a34200 LWU (X5), X6 // 03e30200 LWU 4(X5), X6 // 03e34200 LH (X5), X6 // 03930200 LH 4(X5), X6 // 03934200 LHU (X5), X6 // 03d30200 LHU 4(X5), X6 // 03d34200 LB (X5), X6 // 03830200 LB 4(X5), X6 // 03834200 LBU (X5), X6 // 03c30200 LBU 4(X5), X6 // 03c34200 SW X5, (X6) // 23205300 SW X5, 4(X6) // 23225300 SH X5, (X6) // 23105300 SH X5, 4(X6) // 23125300 SB X5, (X6) // 23005300 SB X5, 4(X6) // 23025300 // 2.7: Memory Ordering Instructions FENCE // 0f00f00f // 5.2: Integer Computational Instructions (RV64I) ADDIW $1, X5, X6 // 1b831200 SLLIW $1, X5, X6 // 1b931200 SRLIW $1, X5, X6 // 1bd31200 SRAIW $1, X5, X6 // 1bd31240 ADDW X5, X6, X7 // bb035300 SLLW X5, X6, X7 // bb135300 SRLW X5, X6, X7 // bb535300 SUBW X5, X6, X7 // bb035340 SRAW X5, X6, X7 // bb535340 ADDIW $1, X6 // 1b031300 SLLIW $1, X6 // 1b131300 SRLIW $1, X6 // 1b531300 SRAIW $1, X6 // 1b531340 ADDW X5, X7 // bb835300 SLLW X5, X7 // bb935300 SRLW X5, X7 // bbd35300 SUBW X5, X7 // bb835340 SRAW X5, X7 // bbd35340 ADDW $1, X6 // 1b031300 SLLW $1, X6 // 1b131300 SRLW $1, X6 // 1b531300 SUBW $1, X6 // 1b03f3ff SRAW $1, X6 // 1b531340 // 5.3: Load and Store Instructions (RV64I) LD (X5), X6 // 03b30200 LD 4(X5), X6 // 03b34200 SD X5, (X6) // 23305300 SD X5, 4(X6) // 23325300 // 7.1: Multiplication Operations MUL X5, X6, X7 // b3035302 MULH X5, X6, X7 // b3135302 MULHU X5, X6, X7 // b3335302 MULHSU X5, X6, X7 // b3235302 MULW X5, X6, X7 // bb035302 DIV X5, X6, X7 // b3435302 DIVU X5, X6, X7 // b3535302 REM X5, X6, X7 // b3635302 REMU X5, X6, X7 // b3735302 DIVW X5, X6, X7 // bb435302 DIVUW X5, X6, X7 // bb535302 REMW X5, X6, X7 // bb635302 REMUW X5, X6, X7 // bb735302 // 8.2: Load-Reserved/Store-Conditional LRW (X5), X6 // 2fa30214 LRD (X5), X6 // 2fb30214 SCW X5, (X6), X7 // af23531a SCD X5, (X6), X7 // af33531a // 8.3: Atomic Memory Operations AMOSWAPW X5, (X6), X7 // af23530e AMOSWAPD X5, (X6), X7 // af33530e AMOADDW X5, (X6), X7 // af235306 AMOADDD X5, (X6), X7 // af335306 AMOANDW X5, (X6), X7 // af235366 AMOANDD X5, (X6), X7 // af335366 AMOORW X5, (X6), X7 // af235346 AMOORD X5, (X6), X7 // af335346 AMOXORW X5, (X6), X7 // af235326 AMOXORD X5, (X6), X7 // af335326 AMOMAXW X5, (X6), X7 // af2353a6 AMOMAXD X5, (X6), X7 // af3353a6 AMOMAXUW X5, (X6), X7 // af2353e6 AMOMAXUD X5, (X6), X7 // af3353e6 AMOMINW X5, (X6), X7 // af235386 AMOMIND X5, (X6), X7 // af335386 AMOMINUW X5, (X6), X7 // af2353c6 AMOMINUD X5, (X6), X7 // af3353c6 // 10.1: Base Counters and Timers RDCYCLE X5 // f32200c0 RDTIME X5 // f32210c0 RDINSTRET X5 // f32220c0 // 11.5: Single-Precision Load and Store Instructions FLW (X5), F0 // 07a00200 FLW 4(X5), F0 // 07a04200 FSW F0, (X5) // 27a00200 FSW F0, 4(X5) // 27a20200 // 11.6: Single-Precision Floating-Point Computational Instructions FADDS F1, F0, F2 // 53011000 FSUBS F1, F0, F2 // 53011008 FMULS F1, F0, F2 // 53011010 FDIVS F1, F0, F2 // 53011018 FMINS F1, F0, F2 // 53011028 FMAXS F1, F0, F2 // 53111028 FSQRTS F0, F1 // d3000058 // 11.7: Single-Precision Floating-Point Conversion and Move Instructions FCVTWS F0, X5 // d31200c0 FCVTWS.RNE F0, X5 // d30200c0 FCVTWS.RTZ F0, X5 // d31200c0 FCVTWS.RDN F0, X5 // d32200c0 FCVTWS.RUP F0, X5 // d33200c0 FCVTWS.RMM F0, X5 // d34200c0 FCVTLS F0, X5 // d31220c0 FCVTLS.RNE F0, X5 // d30220c0 FCVTLS.RTZ F0, X5 // d31220c0 FCVTLS.RDN F0, X5 // d32220c0 FCVTLS.RUP F0, X5 // d33220c0 FCVTLS.RMM F0, X5 // d34220c0 FCVTSW X5, F0 // 538002d0 FCVTSL X5, F0 // 538022d0 FCVTWUS F0, X5 // d31210c0 FCVTWUS.RNE F0, X5 // d30210c0 FCVTWUS.RTZ F0, X5 // d31210c0 FCVTWUS.RDN F0, X5 // d32210c0 FCVTWUS.RUP F0, X5 // d33210c0 FCVTWUS.RMM F0, X5 // d34210c0 FCVTLUS F0, X5 // d31230c0 FCVTLUS.RNE F0, X5 // d30230c0 FCVTLUS.RTZ F0, X5 // d31230c0 FCVTLUS.RDN F0, X5 // d32230c0 FCVTLUS.RUP F0, X5 // d33230c0 FCVTLUS.RMM F0, X5 // d34230c0 FCVTSWU X5, F0 // 538012d0 FCVTSLU X5, F0 // 538032d0 FSGNJS F1, F0, F2 // 53011020 FSGNJNS F1, F0, F2 // 53111020 FSGNJXS F1, F0, F2 // 53211020 FMVXS F0, X5 // d30200e0 FMVSX X5, F0 // 538002f0 FMVXW F0, X5 // d30200e0 FMVWX X5, F0 // 538002f0 FMADDS F1, F2, F3, F4 // 43822018 FMSUBS F1, F2, F3, F4 // 47822018 FNMSUBS F1, F2, F3, F4 // 4b822018 FNMADDS F1, F2, F3, F4 // 4f822018 // 11.8: Single-Precision Floating-Point Compare Instructions FEQS F0, F1, X7 // d3a300a0 FLTS F0, F1, X7 // d39300a0 FLES F0, F1, X7 // d38300a0 // 11.9: Single-Precision Floating-Point Classify Instruction FCLASSS F0, X5 // d31200e0 // 12.3: Double-Precision Load and Store Instructions FLD (X5), F0 // 07b00200 FLD 4(X5), F0 // 07b04200 FSD F0, (X5) // 27b00200 FSD F0, 4(X5) // 27b20200 // 12.4: Double-Precision Floating-Point Computational Instructions FADDD F1, F0, F2 // 53011002 FSUBD F1, F0, F2 // 5301100a FMULD F1, F0, F2 // 53011012 FDIVD F1, F0, F2 // 5301101a FMIND F1, F0, F2 // 5301102a FMAXD F1, F0, F2 // 5311102a FSQRTD F0, F1 // d300005a // 12.5: Double-Precision Floating-Point Conversion and Move Instructions FCVTWD F0, X5 // d31200c2 FCVTWD.RNE F0, X5 // d30200c2 FCVTWD.RTZ F0, X5 // d31200c2 FCVTWD.RDN F0, X5 // d32200c2 FCVTWD.RUP F0, X5 // d33200c2 FCVTWD.RMM F0, X5 // d34200c2 FCVTLD F0, X5 // d31220c2 FCVTLD.RNE F0, X5 // d30220c2 FCVTLD.RTZ F0, X5 // d31220c2 FCVTLD.RDN F0, X5 // d32220c2 FCVTLD.RUP F0, X5 // d33220c2 FCVTLD.RMM F0, X5 // d34220c2 FCVTDW X5, F0 // 538002d2 FCVTDL X5, F0 // 538022d2 FCVTWUD F0, X5 // d31210c2 FCVTWUD.RNE F0, X5 // d30210c2 FCVTWUD.RTZ F0, X5 // d31210c2 FCVTWUD.RDN F0, X5 // d32210c2 FCVTWUD.RUP F0, X5 // d33210c2 FCVTWUD.RMM F0, X5 // d34210c2 FCVTLUD F0, X5 // d31230c2 FCVTLUD.RNE F0, X5 // d30230c2 FCVTLUD.RTZ F0, X5 // d31230c2 FCVTLUD.RDN F0, X5 // d32230c2 FCVTLUD.RUP F0, X5 // d33230c2 FCVTLUD.RMM F0, X5 // d34230c2 FCVTDWU X5, F0 // 538012d2 FCVTDLU X5, F0 // 538032d2 FCVTSD F0, F1 // d3001040 FCVTDS F0, F1 // d3000042 FSGNJD F1, F0, F2 // 53011022 FSGNJND F1, F0, F2 // 53111022 FSGNJXD F1, F0, F2 // 53211022 FMVXD F0, X5 // d30200e2 FMVDX X5, F0 // 538002f2 FMADDD F1, F2, F3, F4 // 4382201a FMSUBD F1, F2, F3, F4 // 4782201a FNMSUBD F1, F2, F3, F4 // 4b82201a FNMADDD F1, F2, F3, F4 // 4f82201a // 12.6: Double-Precision Floating-Point Classify Instruction FCLASSD F0, X5 // d31200e2 // RISC-V Bit-Manipulation ISA-extensions (1.0) // 1.1: Address Generation Instructions (Zba) ADDUW X10, X11, X12 // 3b86a508 ADDUW X10, X11 // bb85a508 SH1ADD X11, X12, X13 // b326b620 SH1ADD X11, X12 // 3326b620 SH1ADDUW X12, X13, X14 // 3ba7c620 SH1ADDUW X12, X13 // bba6c620 SH2ADD X13, X14, X15 // b347d720 SH2ADD X13, X14 // 3347d720 SH2ADDUW X14, X15, X16 // 3bc8e720 SH2ADDUW X14, X15 // bbc7e720 SH3ADD X15, X16, X17 // b368f820 SH3ADD X15, X16 // 3368f820 SH3ADDUW X16, X17, X18 // 3be90821 SH3ADDUW X16, X17 // bbe80821 SLLIUW $31, X17, X18 // 1b99f809 SLLIUW $63, X17 // 9b98f80b SLLIUW $63, X17, X18 // 1b99f80b SLLIUW $1, X18, X19 // 9b191908 // 1.2: Basic Bit Manipulation (Zbb) ANDN X19, X20, X21 // b37a3a41 ANDN X19, X20 // 337a3a41 CLZ X20, X21 // 931a0a60 CLZW X21, X22 // 1b9b0a60 CPOP X22, X23 // 931b2b60 CPOPW X23, X24 // 1b9c2b60 CTZ X24, X25 // 931c1c60 CTZW X25, X26 // 1b9d1c60 MAX X26, X28, X29 // b36eae0b MAX X26, X28 // 336eae0b MAXU X28, X29, X30 // 33ffce0b MAXU X28, X29 // b3fece0b MIN X29, X30, X5 // b342df0b MIN X29, X30 // 334fdf0b MINU X30, X5, X6 // 33d3e20b MINU X30, X5 // b3d2e20b ORN X6, X7, X8 // 33e46340 ORN X6, X7 // b3e36340 SEXTB X16, X17 // 93184860 SEXTH X17, X18 // 13995860 XNOR X18, X19, X20 // 33ca2941 XNOR X18, X19 // b3c92941 ZEXTH X19, X20 // 3bca0908 // 1.3: Bitwise Rotation (Zbb) ROL X8, X9, X10 // 33958460 or b30f8040b3dff4013395840033e5af00 ROL X8, X9 // b3948460 or b30f8040b3dff401b3948400b3e49f00 ROLW X9, X10, X11 // bb159560 or b30f9040bb5ff501bb159500b3e5bf00 ROLW X9, X10 // 3b159560 or b30f9040bb5ff5013b15950033e5af00 ROR X10, X11, X12 // 33d6a560 or b30fa040b39ff50133d6a50033e6cf00 ROR X10, X11 // b3d5a560 or b30fa040b39ff501b3d5a500b3e5bf00 ROR $63, X11 // 93d5f563 or 93dff50393951500b3e5bf00 RORI $63, X11, X12 // 13d6f563 or 93dff5031396150033e6cf00 RORI $1, X12, X13 // 93561660 or 935f16009316f603b3e6df00 RORIW $31, X13, X14 // 1bd7f661 or 9bdff6011b97160033e7ef00 RORIW $1, X14, X15 // 9b571760 or 9b5f17009b17f701b3e7ff00 RORW X15, X16, X17 // bb58f860 or b30ff040bb1ff801bb58f800b3e81f01 RORW X15, X16 // 3b58f860 or b30ff040bb1ff8013b58f80033e80f01 RORW $31, X13 // 9bd6f661 or 9bdff6019b961600b3e6df00 ORCB X5, X6 // 13d37228 REV8 X7, X8 // 13d4836b // 1.5: Single-bit Instructions (Zbs) BCLR X23, X24, X25 // b31c7c49 BCLR $63, X24 // 131cfc4b BCLRI $1, X25, X26 // 139d1c48 BEXT X26, X28, X29 // b35eae49 BEXT $63, X28 // 135efe4b BEXTI $1, X29, X30 // 13df1e48 BINV X30, X5, X6 // 3393e269 BINV $63, X6 // 1313f36b BINVI $1, X7, X8 // 13941368 BSET X8, X9, X10 // 33958428 BSET $63, X9 // 9394f42b BSETI $1, X10, X11 // 93151528 // Privileged ISA // 3.2.1: Environment Call and Breakpoint ECALL // 73000000 SCALL // 73000000 EBREAK // 73001000 SBREAK // 73001000 // Arbitrary bytes (entered in little-endian mode) WORD $0x12345678 // WORD $305419896 // 78563412 WORD $0x9abcdef0 // WORD $2596069104 // f0debc9a // MOV pseudo-instructions MOV X5, X6 // 13830200 MOV $2047, X5 // 9302f07f MOV $-2048, X5 // 93020080 MOV $2048, X5 // b71200009b820280 MOV $-2049, X5 // b7f2ffff9b82f27f MOV $4096, X5 // b7120000 MOV $2147479552, X5 // b7f2ff7f MOV $2147483647, X5 // b70200809b82f2ff MOV $-2147483647, X5 // b70200809b821200 // Converted to load of symbol (AUIPC + LD) MOV $4294967295, X5 // 9702000083b20200 // Converted to MOV $1, X5 + SLLI $32, X5 MOV $4294967296, X5 // 9302100093920202 MOV (X5), X6 // 03b30200 MOV 4(X5), X6 // 03b34200 MOVB (X5), X6 // 03830200 MOVB 4(X5), X6 // 03834200 MOVH (X5), X6 // 03930200 MOVH 4(X5), X6 // 03934200 MOVW (X5), X6 // 03a30200 MOVW 4(X5), X6 // 03a34200 MOV X5, (X6) // 23305300 MOV X5, 4(X6) // 23325300 MOVB X5, (X6) // 23005300 MOVB X5, 4(X6) // 23025300 MOVH X5, (X6) // 23105300 MOVH X5, 4(X6) // 23125300 MOVW X5, (X6) // 23205300 MOVW X5, 4(X6) // 23225300 MOVB X5, X6 // 1393820313538343 or 13934260 MOVH X5, X6 // 1393020313530343 or 13935260 MOVW X5, X6 // 1b830200 MOVBU X5, X6 // 13f3f20f MOVHU X5, X6 // 1393020313530303 or 3bc30208 MOVWU X5, X6 // 1393020213530302 or 3b830208 MOVF 4(X5), F0 // 07a04200 MOVF F0, 4(X5) // 27a20200 MOVF F0, F1 // d3000020 MOVD 4(X5), F0 // 07b04200 MOVD F0, 4(X5) // 27b20200 MOVD F0, F1 // d3000022 // TLS load with local-exec (LUI + ADDIW + ADD of TP + load) MOV tls(SB), X5 // b70f00009b8f0f00b38f4f0083b20f00 MOVB tls(SB), X5 // b70f00009b8f0f00b38f4f0083820f00 // TLS store with local-exec (LUI + ADDIW + ADD of TP + store) MOV X5, tls(SB) // b70f00009b8f0f00b38f4f0023b05f00 MOVB X5, tls(SB) // b70f00009b8f0f00b38f4f0023805f00 // NOT pseudo-instruction NOT X5 // 93c2f2ff NOT X5, X6 // 13c3f2ff // NEG/NEGW pseudo-instructions NEG X5 // b3025040 NEG X5, X6 // 33035040 NEGW X5 // bb025040 NEGW X5, X6 // 3b035040 // This jumps to the second instruction in the function (the // first instruction is an invisible stack pointer adjustment). JMP start // JMP 2 JMP 2(PC) // 6f008000 JMP (X5) // 67800200 JMP 4(X5) // 67804200 // CALL and JMP to symbol are encoded as JAL (using LR or ZERO // respectively), with a R_RISCV_JAL relocation. The linker resolves // the real address and updates the immediate, using a trampoline in // the case where the address is not directly reachable. CALL asmtest(SB) // ef000000 JMP asmtest(SB) // 6f000000 // Branch pseudo-instructions BEQZ X5, 2(PC) // 63840200 BGEZ X5, 2(PC) // 63d40200 BGT X5, X6, 2(PC) // 63445300 BGTU X5, X6, 2(PC) // 63645300 BGTZ X5, 2(PC) // 63445000 BLE X5, X6, 2(PC) // 63545300 BLEU X5, X6, 2(PC) // 63745300 BLEZ X5, 2(PC) // 63545000 BLTZ X5, 2(PC) // 63c40200 BNEZ X5, 2(PC) // 63940200 // Set pseudo-instructions SEQZ X15, X15 // 93b71700 SNEZ X15, X15 // b337f000 // F extension FABSS F0, F1 // d3200020 FNEGS F0, F1 // d3100020 FNES F0, F1, X7 // d3a300a093c31300 // D extension FABSD F0, F1 // d3200022 FNEGD F0, F1 // d3100022 FNED F0, F1, X5 // d3a200a293c21200 FLTD F0, F1, X5 // d39200a2 FLED F0, F1, X5 // d38200a2 FEQD F0, F1, X5 // d3a200a2 GLOBL tls(SB), TLSBSS, $8
go/src/cmd/asm/internal/asm/testdata/riscv64.s/0
{ "file_path": "go/src/cmd/asm/internal/asm/testdata/riscv64.s", "repo_id": "go", "token_count": 10762 }
67
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. /* Cgo enables the creation of Go packages that call C code. # Using cgo with the go command To use cgo write normal Go code that imports a pseudo-package "C". The Go code can then refer to types such as C.size_t, variables such as C.stdout, or functions such as C.putchar. If the import of "C" is immediately preceded by a comment, that comment, called the preamble, is used as a header when compiling the C parts of the package. For example: // #include <stdio.h> // #include <errno.h> import "C" The preamble may contain any C code, including function and variable declarations and definitions. These may then be referred to from Go code as though they were defined in the package "C". All names declared in the preamble may be used, even if they start with a lower-case letter. Exception: static variables in the preamble may not be referenced from Go code; static functions are permitted. See $GOROOT/cmd/cgo/internal/teststdio and $GOROOT/misc/cgo/gmp for examples. See "C? Go? Cgo!" for an introduction to using cgo: https://golang.org/doc/articles/c_go_cgo.html. CFLAGS, CPPFLAGS, CXXFLAGS, FFLAGS and LDFLAGS may be defined with pseudo #cgo directives within these comments to tweak the behavior of the C, C++ or Fortran compiler. Values defined in multiple directives are concatenated together. The directive can include a list of build constraints limiting its effect to systems satisfying one of the constraints (see https://golang.org/pkg/go/build/#hdr-Build_Constraints for details about the constraint syntax). For example: // #cgo CFLAGS: -DPNG_DEBUG=1 // #cgo amd64 386 CFLAGS: -DX86=1 // #cgo LDFLAGS: -lpng // #include <png.h> import "C" Alternatively, CPPFLAGS and LDFLAGS may be obtained via the pkg-config tool using a '#cgo pkg-config:' directive followed by the package names. For example: // #cgo pkg-config: png cairo // #include <png.h> import "C" The default pkg-config tool may be changed by setting the PKG_CONFIG environment variable. For security reasons, only a limited set of flags are allowed, notably -D, -U, -I, and -l. To allow additional flags, set CGO_CFLAGS_ALLOW to a regular expression matching the new flags. To disallow flags that would otherwise be allowed, set CGO_CFLAGS_DISALLOW to a regular expression matching arguments that must be disallowed. In both cases the regular expression must match a full argument: to allow -mfoo=bar, use CGO_CFLAGS_ALLOW='-mfoo.*', not just CGO_CFLAGS_ALLOW='-mfoo'. Similarly named variables control the allowed CPPFLAGS, CXXFLAGS, FFLAGS, and LDFLAGS. Also for security reasons, only a limited set of characters are permitted, notably alphanumeric characters and a few symbols, such as '.', that will not be interpreted in unexpected ways. Attempts to use forbidden characters will get a "malformed #cgo argument" error. When building, the CGO_CFLAGS, CGO_CPPFLAGS, CGO_CXXFLAGS, CGO_FFLAGS and CGO_LDFLAGS environment variables are added to the flags derived from these directives. Package-specific flags should be set using the directives, not the environment variables, so that builds work in unmodified environments. Flags obtained from environment variables are not subject to the security limitations described above. All the cgo CPPFLAGS and CFLAGS directives in a package are concatenated and used to compile C files in that package. All the CPPFLAGS and CXXFLAGS directives in a package are concatenated and used to compile C++ files in that package. All the CPPFLAGS and FFLAGS directives in a package are concatenated and used to compile Fortran files in that package. All the LDFLAGS directives in any package in the program are concatenated and used at link time. All the pkg-config directives are concatenated and sent to pkg-config simultaneously to add to each appropriate set of command-line flags. When the cgo directives are parsed, any occurrence of the string ${SRCDIR} will be replaced by the absolute path to the directory containing the source file. This allows pre-compiled static libraries to be included in the package directory and linked properly. For example if package foo is in the directory /go/src/foo: // #cgo LDFLAGS: -L${SRCDIR}/libs -lfoo Will be expanded to: // #cgo LDFLAGS: -L/go/src/foo/libs -lfoo When the Go tool sees that one or more Go files use the special import "C", it will look for other non-Go files in the directory and compile them as part of the Go package. Any .c, .s, .S or .sx files will be compiled with the C compiler. Any .cc, .cpp, or .cxx files will be compiled with the C++ compiler. Any .f, .F, .for or .f90 files will be compiled with the fortran compiler. Any .h, .hh, .hpp, or .hxx files will not be compiled separately, but, if these header files are changed, the package (including its non-Go source files) will be recompiled. Note that changes to files in other directories do not cause the package to be recompiled, so all non-Go source code for the package should be stored in the package directory, not in subdirectories. The default C and C++ compilers may be changed by the CC and CXX environment variables, respectively; those environment variables may include command line options. The cgo tool will always invoke the C compiler with the source file's directory in the include path; i.e. -I${SRCDIR} is always implied. This means that if a header file foo/bar.h exists both in the source directory and also in the system include directory (or some other place specified by a -I flag), then "#include <foo/bar.h>" will always find the local version in preference to any other version. The cgo tool is enabled by default for native builds on systems where it is expected to work. It is disabled by default when cross-compiling as well as when the CC environment variable is unset and the default C compiler (typically gcc or clang) cannot be found on the system PATH. You can override the default by setting the CGO_ENABLED environment variable when running the go tool: set it to 1 to enable the use of cgo, and to 0 to disable it. The go tool will set the build constraint "cgo" if cgo is enabled. The special import "C" implies the "cgo" build constraint, as though the file also said "//go:build cgo". Therefore, if cgo is disabled, files that import "C" will not be built by the go tool. (For more about build constraints see https://golang.org/pkg/go/build/#hdr-Build_Constraints). When cross-compiling, you must specify a C cross-compiler for cgo to use. You can do this by setting the generic CC_FOR_TARGET or the more specific CC_FOR_${GOOS}_${GOARCH} (for example, CC_FOR_linux_arm) environment variable when building the toolchain using make.bash, or you can set the CC environment variable any time you run the go tool. The CXX_FOR_TARGET, CXX_FOR_${GOOS}_${GOARCH}, and CXX environment variables work in a similar way for C++ code. # Go references to C Within the Go file, C's struct field names that are keywords in Go can be accessed by prefixing them with an underscore: if x points at a C struct with a field named "type", x._type accesses the field. C struct fields that cannot be expressed in Go, such as bit fields or misaligned data, are omitted in the Go struct, replaced by appropriate padding to reach the next field or the end of the struct. The standard C numeric types are available under the names C.char, C.schar (signed char), C.uchar (unsigned char), C.short, C.ushort (unsigned short), C.int, C.uint (unsigned int), C.long, C.ulong (unsigned long), C.longlong (long long), C.ulonglong (unsigned long long), C.float, C.double, C.complexfloat (complex float), and C.complexdouble (complex double). The C type void* is represented by Go's unsafe.Pointer. The C types __int128_t and __uint128_t are represented by [16]byte. A few special C types which would normally be represented by a pointer type in Go are instead represented by a uintptr. See the Special cases section below. To access a struct, union, or enum type directly, prefix it with struct_, union_, or enum_, as in C.struct_stat. The size of any C type T is available as C.sizeof_T, as in C.sizeof_struct_stat. A C function may be declared in the Go file with a parameter type of the special name _GoString_. This function may be called with an ordinary Go string value. The string length, and a pointer to the string contents, may be accessed by calling the C functions size_t _GoStringLen(_GoString_ s); const char *_GoStringPtr(_GoString_ s); These functions are only available in the preamble, not in other C files. The C code must not modify the contents of the pointer returned by _GoStringPtr. Note that the string contents may not have a trailing NUL byte. As Go doesn't have support for C's union type in the general case, C's union types are represented as a Go byte array with the same length. Go structs cannot embed fields with C types. Go code cannot refer to zero-sized fields that occur at the end of non-empty C structs. To get the address of such a field (which is the only operation you can do with a zero-sized field) you must take the address of the struct and add the size of the struct. Cgo translates C types into equivalent unexported Go types. Because the translations are unexported, a Go package should not expose C types in its exported API: a C type used in one Go package is different from the same C type used in another. Any C function (even void functions) may be called in a multiple assignment context to retrieve both the return value (if any) and the C errno variable as an error (use _ to skip the result value if the function returns void). For example: n, err = C.sqrt(-1) _, err := C.voidFunc() var n, err = C.sqrt(1) Calling C function pointers is currently not supported, however you can declare Go variables which hold C function pointers and pass them back and forth between Go and C. C code may call function pointers received from Go. For example: package main // typedef int (*intFunc) (); // // int // bridge_int_func(intFunc f) // { // return f(); // } // // int fortytwo() // { // return 42; // } import "C" import "fmt" func main() { f := C.intFunc(C.fortytwo) fmt.Println(int(C.bridge_int_func(f))) // Output: 42 } In C, a function argument written as a fixed size array actually requires a pointer to the first element of the array. C compilers are aware of this calling convention and adjust the call accordingly, but Go cannot. In Go, you must pass the pointer to the first element explicitly: C.f(&C.x[0]). Calling variadic C functions is not supported. It is possible to circumvent this by using a C function wrapper. For example: package main // #include <stdio.h> // #include <stdlib.h> // // static void myprint(char* s) { // printf("%s\n", s); // } import "C" import "unsafe" func main() { cs := C.CString("Hello from stdio") C.myprint(cs) C.free(unsafe.Pointer(cs)) } A few special functions convert between Go and C types by making copies of the data. In pseudo-Go definitions: // Go string to C string // The C string is allocated in the C heap using malloc. // It is the caller's responsibility to arrange for it to be // freed, such as by calling C.free (be sure to include stdlib.h // if C.free is needed). func C.CString(string) *C.char // Go []byte slice to C array // The C array is allocated in the C heap using malloc. // It is the caller's responsibility to arrange for it to be // freed, such as by calling C.free (be sure to include stdlib.h // if C.free is needed). func C.CBytes([]byte) unsafe.Pointer // C string to Go string func C.GoString(*C.char) string // C data with explicit length to Go string func C.GoStringN(*C.char, C.int) string // C data with explicit length to Go []byte func C.GoBytes(unsafe.Pointer, C.int) []byte As a special case, C.malloc does not call the C library malloc directly but instead calls a Go helper function that wraps the C library malloc but guarantees never to return nil. If C's malloc indicates out of memory, the helper function crashes the program, like when Go itself runs out of memory. Because C.malloc cannot fail, it has no two-result form that returns errno. # C references to Go Go functions can be exported for use by C code in the following way: //export MyFunction func MyFunction(arg1, arg2 int, arg3 string) int64 {...} //export MyFunction2 func MyFunction2(arg1, arg2 int, arg3 string) (int64, *C.char) {...} They will be available in the C code as: extern GoInt64 MyFunction(int arg1, int arg2, GoString arg3); extern struct MyFunction2_return MyFunction2(int arg1, int arg2, GoString arg3); found in the _cgo_export.h generated header, after any preambles copied from the cgo input files. Functions with multiple return values are mapped to functions returning a struct. Not all Go types can be mapped to C types in a useful way. Go struct types are not supported; use a C struct type. Go array types are not supported; use a C pointer. Go functions that take arguments of type string may be called with the C type _GoString_, described above. The _GoString_ type will be automatically defined in the preamble. Note that there is no way for C code to create a value of this type; this is only useful for passing string values from Go to C and back to Go. Using //export in a file places a restriction on the preamble: since it is copied into two different C output files, it must not contain any definitions, only declarations. If a file contains both definitions and declarations, then the two output files will produce duplicate symbols and the linker will fail. To avoid this, definitions must be placed in preambles in other files, or in C source files. # Passing pointers Go is a garbage collected language, and the garbage collector needs to know the location of every pointer to Go memory. Because of this, there are restrictions on passing pointers between Go and C. In this section the term Go pointer means a pointer to memory allocated by Go (such as by using the & operator or calling the predefined new function) and the term C pointer means a pointer to memory allocated by C (such as by a call to C.malloc). Whether a pointer is a Go pointer or a C pointer is a dynamic property determined by how the memory was allocated; it has nothing to do with the type of the pointer. Note that values of some Go types, other than the type's zero value, always include Go pointers. This is true of string, slice, interface, channel, map, and function types. A pointer type may hold a Go pointer or a C pointer. Array and struct types may or may not include Go pointers, depending on the element types. All the discussion below about Go pointers applies not just to pointer types, but also to other types that include Go pointers. All Go pointers passed to C must point to pinned Go memory. Go pointers passed as function arguments to C functions have the memory they point to implicitly pinned for the duration of the call. Go memory reachable from these function arguments must be pinned as long as the C code has access to it. Whether Go memory is pinned is a dynamic property of that memory region; it has nothing to do with the type of the pointer. Go values created by calling new, by taking the address of a composite literal, or by taking the address of a local variable may also have their memory pinned using [runtime.Pinner]. This type may be used to manage the duration of the memory's pinned status, potentially beyond the duration of a C function call. Memory may be pinned more than once and must be unpinned exactly the same number of times it has been pinned. Go code may pass a Go pointer to C provided the memory to which it points does not contain any Go pointers to memory that is unpinned. When passing a pointer to a field in a struct, the Go memory in question is the memory occupied by the field, not the entire struct. When passing a pointer to an element in an array or slice, the Go memory in question is the entire array or the entire backing array of the slice. C code may keep a copy of a Go pointer only as long as the memory it points to is pinned. C code may not keep a copy of a Go pointer after the call returns, unless the memory it points to is pinned with [runtime.Pinner] and the Pinner is not unpinned while the Go pointer is stored in C memory. This implies that C code may not keep a copy of a string, slice, channel, and so forth, because they cannot be pinned with [runtime.Pinner]. The _GoString_ type also may not be pinned with [runtime.Pinner]. Because it includes a Go pointer, the memory it points to is only pinned for the duration of the call; _GoString_ values may not be retained by C code. A Go function called by C code may return a Go pointer to pinned memory (which implies that it may not return a string, slice, channel, and so forth). A Go function called by C code may take C pointers as arguments, and it may store non-pointer data, C pointers, or Go pointers to pinned memory through those pointers. It may not store a Go pointer to unpinned memory in memory pointed to by a C pointer (which again, implies that it may not store a string, slice, channel, and so forth). A Go function called by C code may take a Go pointer but it must preserve the property that the Go memory to which it points (and the Go memory to which that memory points, and so on) is pinned. These rules are checked dynamically at runtime. The checking is controlled by the cgocheck setting of the GODEBUG environment variable. The default setting is GODEBUG=cgocheck=1, which implements reasonably cheap dynamic checks. These checks may be disabled entirely using GODEBUG=cgocheck=0. Complete checking of pointer handling, at some cost in run time, is available by setting GOEXPERIMENT=cgocheck2 at build time. It is possible to defeat this enforcement by using the unsafe package, and of course there is nothing stopping the C code from doing anything it likes. However, programs that break these rules are likely to fail in unexpected and unpredictable ways. The runtime/cgo.Handle type can be used to safely pass Go values between Go and C. See the runtime/cgo package documentation for details. Note: the current implementation has a bug. While Go code is permitted to write nil or a C pointer (but not a Go pointer) to C memory, the current implementation may sometimes cause a runtime error if the contents of the C memory appear to be a Go pointer. Therefore, avoid passing uninitialized C memory to Go code if the Go code is going to store pointer values in it. Zero out the memory in C before passing it to Go. # Special cases A few special C types which would normally be represented by a pointer type in Go are instead represented by a uintptr. Those include: 1. The *Ref types on Darwin, rooted at CoreFoundation's CFTypeRef type. 2. The object types from Java's JNI interface: jobject jclass jthrowable jstring jarray jbooleanArray jbyteArray jcharArray jshortArray jintArray jlongArray jfloatArray jdoubleArray jobjectArray jweak 3. The EGLDisplay and EGLConfig types from the EGL API. These types are uintptr on the Go side because they would otherwise confuse the Go garbage collector; they are sometimes not really pointers but data structures encoded in a pointer type. All operations on these types must happen in C. The proper constant to initialize an empty such reference is 0, not nil. These special cases were introduced in Go 1.10. For auto-updating code from Go 1.9 and earlier, use the cftype or jni rewrites in the Go fix tool: go tool fix -r cftype <pkg> go tool fix -r jni <pkg> It will replace nil with 0 in the appropriate places. The EGLDisplay case was introduced in Go 1.12. Use the egl rewrite to auto-update code from Go 1.11 and earlier: go tool fix -r egl <pkg> The EGLConfig case was introduced in Go 1.15. Use the eglconf rewrite to auto-update code from Go 1.14 and earlier: go tool fix -r eglconf <pkg> # Using cgo directly Usage: go tool cgo [cgo options] [-- compiler options] gofiles... Cgo transforms the specified input Go source files into several output Go and C source files. The compiler options are passed through uninterpreted when invoking the C compiler to compile the C parts of the package. The following options are available when running cgo directly: -V Print cgo version and exit. -debug-define Debugging option. Print #defines. -debug-gcc Debugging option. Trace C compiler execution and output. -dynimport file Write list of symbols imported by file. Write to -dynout argument or to standard output. Used by go build when building a cgo package. -dynlinker Write dynamic linker as part of -dynimport output. -dynout file Write -dynimport output to file. -dynpackage package Set Go package for -dynimport output. -exportheader file If there are any exported functions, write the generated export declarations to file. C code can #include this to see the declarations. -importpath string The import path for the Go package. Optional; used for nicer comments in the generated files. -import_runtime_cgo If set (which it is by default) import runtime/cgo in generated output. -import_syscall If set (which it is by default) import syscall in generated output. -gccgo Generate output for the gccgo compiler rather than the gc compiler. -gccgoprefix prefix The -fgo-prefix option to be used with gccgo. -gccgopkgpath path The -fgo-pkgpath option to be used with gccgo. -gccgo_define_cgoincomplete Define cgo.Incomplete locally rather than importing it from the "runtime/cgo" package. Used for old gccgo versions. -godefs Write out input file in Go syntax replacing C package names with real values. Used to generate files in the syscall package when bootstrapping a new target. -ldflags flags Flags to pass to the C linker. The cmd/go tool uses this to pass in the flags in the CGO_LDFLAGS variable. -objdir directory Put all generated files in directory. -srcdir directory */ package main /* Implementation details. Cgo provides a way for Go programs to call C code linked into the same address space. This comment explains the operation of cgo. Cgo reads a set of Go source files and looks for statements saying import "C". If the import has a doc comment, that comment is taken as literal C code to be used as a preamble to any C code generated by cgo. A typical preamble #includes necessary definitions: // #include <stdio.h> import "C" For more details about the usage of cgo, see the documentation comment at the top of this file. Understanding C Cgo scans the Go source files that import "C" for uses of that package, such as C.puts. It collects all such identifiers. The next step is to determine each kind of name. In C.xxx the xxx might refer to a type, a function, a constant, or a global variable. Cgo must decide which. The obvious thing for cgo to do is to process the preamble, expanding #includes and processing the corresponding C code. That would require a full C parser and type checker that was also aware of any extensions known to the system compiler (for example, all the GNU C extensions) as well as the system-specific header locations and system-specific pre-#defined macros. This is certainly possible to do, but it is an enormous amount of work. Cgo takes a different approach. It determines the meaning of C identifiers not by parsing C code but by feeding carefully constructed programs into the system C compiler and interpreting the generated error messages, debug information, and object files. In practice, parsing these is significantly less work and more robust than parsing C source. Cgo first invokes gcc -E -dM on the preamble, in order to find out about simple #defines for constants and the like. These are recorded for later use. Next, cgo needs to identify the kinds for each identifier. For the identifiers C.foo, cgo generates this C program: <preamble> #line 1 "not-declared" void __cgo_f_1_1(void) { __typeof__(foo) *__cgo_undefined__1; } #line 1 "not-type" void __cgo_f_1_2(void) { foo *__cgo_undefined__2; } #line 1 "not-int-const" void __cgo_f_1_3(void) { enum { __cgo_undefined__3 = (foo)*1 }; } #line 1 "not-num-const" void __cgo_f_1_4(void) { static const double __cgo_undefined__4 = (foo); } #line 1 "not-str-lit" void __cgo_f_1_5(void) { static const char __cgo_undefined__5[] = (foo); } This program will not compile, but cgo can use the presence or absence of an error message on a given line to deduce the information it needs. The program is syntactically valid regardless of whether each name is a type or an ordinary identifier, so there will be no syntax errors that might stop parsing early. An error on not-declared:1 indicates that foo is undeclared. An error on not-type:1 indicates that foo is not a type (if declared at all, it is an identifier). An error on not-int-const:1 indicates that foo is not an integer constant. An error on not-num-const:1 indicates that foo is not a number constant. An error on not-str-lit:1 indicates that foo is not a string literal. An error on not-signed-int-const:1 indicates that foo is not a signed integer constant. The line number specifies the name involved. In the example, 1 is foo. Next, cgo must learn the details of each type, variable, function, or constant. It can do this by reading object files. If cgo has decided that t1 is a type, v2 and v3 are variables or functions, and i4, i5 are integer constants, u6 is an unsigned integer constant, and f7 and f8 are float constants, and s9 and s10 are string constants, it generates: <preamble> __typeof__(t1) *__cgo__1; __typeof__(v2) *__cgo__2; __typeof__(v3) *__cgo__3; __typeof__(i4) *__cgo__4; enum { __cgo_enum__4 = i4 }; __typeof__(i5) *__cgo__5; enum { __cgo_enum__5 = i5 }; __typeof__(u6) *__cgo__6; enum { __cgo_enum__6 = u6 }; __typeof__(f7) *__cgo__7; __typeof__(f8) *__cgo__8; __typeof__(s9) *__cgo__9; __typeof__(s10) *__cgo__10; long long __cgodebug_ints[] = { 0, // t1 0, // v2 0, // v3 i4, i5, u6, 0, // f7 0, // f8 0, // s9 0, // s10 1 }; double __cgodebug_floats[] = { 0, // t1 0, // v2 0, // v3 0, // i4 0, // i5 0, // u6 f7, f8, 0, // s9 0, // s10 1 }; const char __cgodebug_str__9[] = s9; const unsigned long long __cgodebug_strlen__9 = sizeof(s9)-1; const char __cgodebug_str__10[] = s10; const unsigned long long __cgodebug_strlen__10 = sizeof(s10)-1; and again invokes the system C compiler, to produce an object file containing debug information. Cgo parses the DWARF debug information for __cgo__N to learn the type of each identifier. (The types also distinguish functions from global variables.) Cgo reads the constant values from the __cgodebug_* from the object file's data segment. At this point cgo knows the meaning of each C.xxx well enough to start the translation process. Translating Go Given the input Go files x.go and y.go, cgo generates these source files: x.cgo1.go # for gc (cmd/compile) y.cgo1.go # for gc _cgo_gotypes.go # for gc _cgo_import.go # for gc (if -dynout _cgo_import.go) x.cgo2.c # for gcc y.cgo2.c # for gcc _cgo_defun.c # for gcc (if -gccgo) _cgo_export.c # for gcc _cgo_export.h # for gcc _cgo_main.c # for gcc _cgo_flags # for build tool (if -gccgo) The file x.cgo1.go is a copy of x.go with the import "C" removed and references to C.xxx replaced with names like _Cfunc_xxx or _Ctype_xxx. The definitions of those identifiers, written as Go functions, types, or variables, are provided in _cgo_gotypes.go. Here is a _cgo_gotypes.go containing definitions for needed C types: type _Ctype_char int8 type _Ctype_int int32 type _Ctype_void [0]byte The _cgo_gotypes.go file also contains the definitions of the functions. They all have similar bodies that invoke runtime·cgocall to make a switch from the Go runtime world to the system C (GCC-based) world. For example, here is the definition of _Cfunc_puts: //go:cgo_import_static _cgo_be59f0f25121_Cfunc_puts //go:linkname __cgofn__cgo_be59f0f25121_Cfunc_puts _cgo_be59f0f25121_Cfunc_puts var __cgofn__cgo_be59f0f25121_Cfunc_puts byte var _cgo_be59f0f25121_Cfunc_puts = unsafe.Pointer(&__cgofn__cgo_be59f0f25121_Cfunc_puts) func _Cfunc_puts(p0 *_Ctype_char) (r1 _Ctype_int) { _cgo_runtime_cgocall(_cgo_be59f0f25121_Cfunc_puts, uintptr(unsafe.Pointer(&p0))) return } The hexadecimal number is a hash of cgo's input, chosen to be deterministic yet unlikely to collide with other uses. The actual function _cgo_be59f0f25121_Cfunc_puts is implemented in a C source file compiled by gcc, the file x.cgo2.c: void _cgo_be59f0f25121_Cfunc_puts(void *v) { struct { char* p0; int r; char __pad12[4]; } __attribute__((__packed__, __gcc_struct__)) *a = v; a->r = puts((void*)a->p0); } It extracts the arguments from the pointer to _Cfunc_puts's argument frame, invokes the system C function (in this case, puts), stores the result in the frame, and returns. Linking Once the _cgo_export.c and *.cgo2.c files have been compiled with gcc, they need to be linked into the final binary, along with the libraries they might depend on (in the case of puts, stdio). cmd/link has been extended to understand basic ELF files, but it does not understand ELF in the full complexity that modern C libraries embrace, so it cannot in general generate direct references to the system libraries. Instead, the build process generates an object file using dynamic linkage to the desired libraries. The main function is provided by _cgo_main.c: int main() { return 0; } void crosscall2(void(*fn)(void*), void *a, int c, uintptr_t ctxt) { } uintptr_t _cgo_wait_runtime_init_done(void) { return 0; } void _cgo_release_context(uintptr_t ctxt) { } char* _cgo_topofstack(void) { return (char*)0; } void _cgo_allocate(void *a, int c) { } void _cgo_panic(void *a, int c) { } void _cgo_reginit(void) { } The extra functions here are stubs to satisfy the references in the C code generated for gcc. The build process links this stub, along with _cgo_export.c and *.cgo2.c, into a dynamic executable and then lets cgo examine the executable. Cgo records the list of shared library references and resolved names and writes them into a new file _cgo_import.go, which looks like: //go:cgo_dynamic_linker "/lib64/ld-linux-x86-64.so.2" //go:cgo_import_dynamic puts puts#GLIBC_2.2.5 "libc.so.6" //go:cgo_import_dynamic __libc_start_main __libc_start_main#GLIBC_2.2.5 "libc.so.6" //go:cgo_import_dynamic stdout stdout#GLIBC_2.2.5 "libc.so.6" //go:cgo_import_dynamic fflush fflush#GLIBC_2.2.5 "libc.so.6" //go:cgo_import_dynamic _ _ "libpthread.so.0" //go:cgo_import_dynamic _ _ "libc.so.6" In the end, the compiled Go package, which will eventually be presented to cmd/link as part of a larger program, contains: _go_.o # gc-compiled object for _cgo_gotypes.go, _cgo_import.go, *.cgo1.go _all.o # gcc-compiled object for _cgo_export.c, *.cgo2.c If there is an error generating the _cgo_import.go file, then, instead of adding _cgo_import.go to the package, the go tool adds an empty file named dynimportfail. The _cgo_import.go file is only needed when using internal linking mode, which is not the default when linking programs that use cgo (as described below). If the linker sees a file named dynimportfail it reports an error if it has been told to use internal linking mode. This approach is taken because generating _cgo_import.go requires doing a full C link of the package, which can fail for reasons that are irrelevant when using external linking mode. The final program will be a dynamic executable, so that cmd/link can avoid needing to process arbitrary .o files. It only needs to process the .o files generated from C files that cgo writes, and those are much more limited in the ELF or other features that they use. In essence, the _cgo_import.o file includes the extra linking directives that cmd/link is not sophisticated enough to derive from _all.o on its own. Similarly, the _all.o uses dynamic references to real system object code because cmd/link is not sophisticated enough to process the real code. The main benefits of this system are that cmd/link remains relatively simple (it does not need to implement a complete ELF and Mach-O linker) and that gcc is not needed after the package is compiled. For example, package net uses cgo for access to name resolution functions provided by libc. Although gcc is needed to compile package net, gcc is not needed to link programs that import package net. Runtime When using cgo, Go must not assume that it owns all details of the process. In particular it needs to coordinate with C in the use of threads and thread-local storage. The runtime package declares a few variables: var ( iscgo bool _cgo_init unsafe.Pointer _cgo_thread_start unsafe.Pointer ) Any package using cgo imports "runtime/cgo", which provides initializations for these variables. It sets iscgo to true, _cgo_init to a gcc-compiled function that can be called early during program startup, and _cgo_thread_start to a gcc-compiled function that can be used to create a new thread, in place of the runtime's usual direct system calls. Internal and External Linking The text above describes "internal" linking, in which cmd/link parses and links host object files (ELF, Mach-O, PE, and so on) into the final executable itself. Keeping cmd/link simple means we cannot possibly implement the full semantics of the host linker, so the kinds of objects that can be linked directly into the binary is limited (other code can only be used as a dynamic library). On the other hand, when using internal linking, cmd/link can generate Go binaries by itself. In order to allow linking arbitrary object files without requiring dynamic libraries, cgo supports an "external" linking mode too. In external linking mode, cmd/link does not process any host object files. Instead, it collects all the Go code and writes a single go.o object file containing it. Then it invokes the host linker (usually gcc) to combine the go.o object file and any supporting non-Go code into a final executable. External linking avoids the dynamic library requirement but introduces a requirement that the host linker be present to create such a binary. Most builds both compile source code and invoke the linker to create a binary. When cgo is involved, the compile step already requires gcc, so it is not problematic for the link step to require gcc too. An important exception is builds using a pre-compiled copy of the standard library. In particular, package net uses cgo on most systems, and we want to preserve the ability to compile pure Go code that imports net without requiring gcc to be present at link time. (In this case, the dynamic library requirement is less significant, because the only library involved is libc.so, which can usually be assumed present.) This conflict between functionality and the gcc requirement means we must support both internal and external linking, depending on the circumstances: if net is the only cgo-using package, then internal linking is probably fine, but if other packages are involved, so that there are dependencies on libraries beyond libc, external linking is likely to work better. The compilation of a package records the relevant information to support both linking modes, leaving the decision to be made when linking the final binary. Linking Directives In either linking mode, package-specific directives must be passed through to cmd/link. These are communicated by writing //go: directives in a Go source file compiled by gc. The directives are copied into the .o object file and then processed by the linker. The directives are: //go:cgo_import_dynamic <local> [<remote> ["<library>"]] In internal linking mode, allow an unresolved reference to <local>, assuming it will be resolved by a dynamic library symbol. The optional <remote> specifies the symbol's name and possibly version in the dynamic library, and the optional "<library>" names the specific library where the symbol should be found. On AIX, the library pattern is slightly different. It must be "lib.a/obj.o" with obj.o the member of this library exporting this symbol. In the <remote>, # or @ can be used to introduce a symbol version. Examples: //go:cgo_import_dynamic puts //go:cgo_import_dynamic puts puts#GLIBC_2.2.5 //go:cgo_import_dynamic puts puts#GLIBC_2.2.5 "libc.so.6" A side effect of the cgo_import_dynamic directive with a library is to make the final binary depend on that dynamic library. To get the dependency without importing any specific symbols, use _ for local and remote. Example: //go:cgo_import_dynamic _ _ "libc.so.6" For compatibility with current versions of SWIG, #pragma dynimport is an alias for //go:cgo_import_dynamic. //go:cgo_dynamic_linker "<path>" In internal linking mode, use "<path>" as the dynamic linker in the final binary. This directive is only needed from one package when constructing a binary; by convention it is supplied by runtime/cgo. Example: //go:cgo_dynamic_linker "/lib/ld-linux.so.2" //go:cgo_export_dynamic <local> <remote> In internal linking mode, put the Go symbol named <local> into the program's exported symbol table as <remote>, so that C code can refer to it by that name. This mechanism makes it possible for C code to call back into Go or to share Go's data. For compatibility with current versions of SWIG, #pragma dynexport is an alias for //go:cgo_export_dynamic. //go:cgo_import_static <local> In external linking mode, allow unresolved references to <local> in the go.o object file prepared for the host linker, under the assumption that <local> will be supplied by the other object files that will be linked with go.o. Example: //go:cgo_import_static puts_wrapper //go:cgo_export_static <local> <remote> In external linking mode, put the Go symbol named <local> into the program's exported symbol table as <remote>, so that C code can refer to it by that name. This mechanism makes it possible for C code to call back into Go or to share Go's data. //go:cgo_ldflag "<arg>" In external linking mode, invoke the host linker (usually gcc) with "<arg>" as a command-line argument following the .o files. Note that the arguments are for "gcc", not "ld". Example: //go:cgo_ldflag "-lpthread" //go:cgo_ldflag "-L/usr/local/sqlite3/lib" A package compiled with cgo will include directives for both internal and external linking; the linker will select the appropriate subset for the chosen linking mode. Example As a simple example, consider a package that uses cgo to call C.sin. The following code will be generated by cgo: // compiled by gc //go:cgo_ldflag "-lm" type _Ctype_double float64 //go:cgo_import_static _cgo_gcc_Cfunc_sin //go:linkname __cgo_gcc_Cfunc_sin _cgo_gcc_Cfunc_sin var __cgo_gcc_Cfunc_sin byte var _cgo_gcc_Cfunc_sin = unsafe.Pointer(&__cgo_gcc_Cfunc_sin) func _Cfunc_sin(p0 _Ctype_double) (r1 _Ctype_double) { _cgo_runtime_cgocall(_cgo_gcc_Cfunc_sin, uintptr(unsafe.Pointer(&p0))) return } // compiled by gcc, into foo.cgo2.o void _cgo_gcc_Cfunc_sin(void *v) { struct { double p0; double r; } __attribute__((__packed__)) *a = v; a->r = sin(a->p0); } What happens at link time depends on whether the final binary is linked using the internal or external mode. If other packages are compiled in "external only" mode, then the final link will be an external one. Otherwise the link will be an internal one. The linking directives are used according to the kind of final link used. In internal mode, cmd/link itself processes all the host object files, in particular foo.cgo2.o. To do so, it uses the cgo_import_dynamic and cgo_dynamic_linker directives to learn that the otherwise undefined reference to sin in foo.cgo2.o should be rewritten to refer to the symbol sin with version GLIBC_2.2.5 from the dynamic library "libm.so.6", and the binary should request "/lib/ld-linux.so.2" as its runtime dynamic linker. In external mode, cmd/link does not process any host object files, in particular foo.cgo2.o. It links together the gc-generated object files, along with any other Go code, into a go.o file. While doing that, cmd/link will discover that there is no definition for _cgo_gcc_Cfunc_sin, referred to by the gc-compiled source file. This is okay, because cmd/link also processes the cgo_import_static directive and knows that _cgo_gcc_Cfunc_sin is expected to be supplied by a host object file, so cmd/link does not treat the missing symbol as an error when creating go.o. Indeed, the definition for _cgo_gcc_Cfunc_sin will be provided to the host linker by foo2.cgo.o, which in turn will need the symbol 'sin'. cmd/link also processes the cgo_ldflag directives, so that it knows that the eventual host link command must include the -lm argument, so that the host linker will be able to find 'sin' in the math library. cmd/link Command Line Interface The go command and any other Go-aware build systems invoke cmd/link to link a collection of packages into a single binary. By default, cmd/link will present the same interface it does today: cmd/link main.a produces a file named a.out, even if cmd/link does so by invoking the host linker in external linking mode. By default, cmd/link will decide the linking mode as follows: if the only packages using cgo are those on a list of known standard library packages (net, os/user, runtime/cgo), cmd/link will use internal linking mode. Otherwise, there are non-standard cgo packages involved, and cmd/link will use external linking mode. The first rule means that a build of the godoc binary, which uses net but no other cgo, can run without needing gcc available. The second rule means that a build of a cgo-wrapped library like sqlite3 can generate a standalone executable instead of needing to refer to a dynamic library. The specific choice can be overridden using a command line flag: cmd/link -linkmode=internal or cmd/link -linkmode=external. In an external link, cmd/link will create a temporary directory, write any host object files found in package archives to that directory (renamed to avoid conflicts), write the go.o file to that directory, and invoke the host linker. The default value for the host linker is $CC, split into fields, or else "gcc". The specific host linker command line can be overridden using command line flags: cmd/link -extld=clang -extldflags='-ggdb -O3'. If any package in a build includes a .cc or other file compiled by the C++ compiler, the go tool will use the -extld option to set the host linker to the C++ compiler. These defaults mean that Go-aware build systems can ignore the linking changes and keep running plain 'cmd/link' and get reasonable results, but they can also control the linking details if desired. */
go/src/cmd/cgo/doc.go/0
{ "file_path": "go/src/cmd/cgo/doc.go", "repo_id": "go", "token_count": 12720 }
68
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build gccgo #include "_cgo_export.h" #include <stdint.h> #include <stdio.h> #include <stdlib.h> /* Test calling panic from C. This is what SWIG does. */ extern void _cgo_panic(const char *); extern void *_cgo_allocate(size_t); void callPanic(void) { _cgo_panic("panic from C"); }
go/src/cmd/cgo/internal/test/callback_c_gccgo.c/0
{ "file_path": "go/src/cmd/cgo/internal/test/callback_c_gccgo.c", "repo_id": "go", "token_count": 163 }
69
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build cgo && !windows // Issue 18146: pthread_create failure during syscall.Exec. package cgotest import ( "bytes" "crypto/md5" "os" "os/exec" "runtime" "syscall" "testing" "time" ) func test18146(t *testing.T) { if testing.Short() { t.Skip("skipping in short mode") } if runtime.GOOS == "darwin" || runtime.GOOS == "ios" { t.Skipf("skipping flaky test on %s; see golang.org/issue/18202", runtime.GOOS) } if runtime.GOARCH == "mips" || runtime.GOARCH == "mips64" { t.Skipf("skipping on %s", runtime.GOARCH) } attempts := 1000 threads := 4 // Restrict the number of attempts based on RLIMIT_NPROC. // Tediously, RLIMIT_NPROC was left out of the syscall package, // probably because it is not in POSIX.1, so we define it here. // It is not defined on Solaris. var nproc int setNproc := true switch runtime.GOOS { default: setNproc = false case "aix": nproc = 9 case "linux": nproc = 6 case "darwin", "dragonfly", "freebsd", "netbsd", "openbsd": nproc = 7 } if setNproc { var rlim syscall.Rlimit if syscall.Getrlimit(nproc, &rlim) == nil { max := int(rlim.Cur) / (threads + 5) if attempts > max { t.Logf("lowering attempts from %d to %d for RLIMIT_NPROC", attempts, max) attempts = max } } } if os.Getenv("test18146") == "exec" { runtime.GOMAXPROCS(1) for n := threads; n > 0; n-- { go func() { for { _ = md5.Sum([]byte("Hello, !")) } }() } runtime.GOMAXPROCS(threads) argv := append(os.Args, "-test.run=^$") if err := syscall.Exec(os.Args[0], argv, os.Environ()); err != nil { t.Fatal(err) } } var cmds []*exec.Cmd defer func() { for _, cmd := range cmds { cmd.Process.Kill() } }() args := append(append([]string(nil), os.Args[1:]...), "-test.run=^Test18146$") for n := attempts; n > 0; n-- { cmd := exec.Command(os.Args[0], args...) cmd.Env = append(os.Environ(), "test18146=exec") buf := bytes.NewBuffer(nil) cmd.Stdout = buf cmd.Stderr = buf if err := cmd.Start(); err != nil { // We are starting so many processes that on // some systems (problem seen on Darwin, // Dragonfly, OpenBSD) the fork call will fail // with EAGAIN. if pe, ok := err.(*os.PathError); ok { err = pe.Err } if se, ok := err.(syscall.Errno); ok && (se == syscall.EAGAIN || se == syscall.EMFILE) { time.Sleep(time.Millisecond) continue } t.Error(err) return } cmds = append(cmds, cmd) } failures := 0 for _, cmd := range cmds { err := cmd.Wait() if err == nil { continue } t.Errorf("syscall.Exec failed: %v\n%s", err, cmd.Stdout) failures++ } if failures > 0 { t.Logf("Failed %v of %v attempts.", failures, len(cmds)) } }
go/src/cmd/cgo/internal/test/issue18146.go/0
{ "file_path": "go/src/cmd/cgo/internal/test/issue18146.go", "repo_id": "go", "token_count": 1240 }
70
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // It's going to be hard to include a whole real JVM to test this. // So we'll simulate a really easy JVM using just the parts we need. // This is the relevant part of jni.h. // On Android NDK16, jobject is defined like this in C and C++ typedef void* jobject; typedef jobject jclass; typedef jobject jthrowable; typedef jobject jstring; typedef jobject jarray; typedef jarray jbooleanArray; typedef jarray jbyteArray; typedef jarray jcharArray; typedef jarray jshortArray; typedef jarray jintArray; typedef jarray jlongArray; typedef jarray jfloatArray; typedef jarray jdoubleArray; typedef jarray jobjectArray; typedef jobject jweak; // Note: jvalue is already a non-pointer type due to it being a C union.
go/src/cmd/cgo/internal/test/issue26213/jni.h/0
{ "file_path": "go/src/cmd/cgo/internal/test/issue26213/jni.h", "repo_id": "go", "token_count": 282 }
71
// Copyright 2019 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build cgo // Issue 30527: function call rewriting casts untyped // constants to int because of ":=" usage. package cgotest import "cmd/cgo/internal/test/issue30527" func issue30527G() { issue30527.G(nil) }
go/src/cmd/cgo/internal/test/issue30527.go/0
{ "file_path": "go/src/cmd/cgo/internal/test/issue30527.go", "repo_id": "go", "token_count": 118 }
72
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 8148. A typedef of an unnamed struct didn't work when used // with an exported Go function. No runtime test; just make sure it // compiles. package cgotest /* typedef struct { int i; } T; int get8148(void); */ import "C" //export issue8148Callback func issue8148Callback(t *C.T) C.int { return t.i } func Issue8148() int { return int(C.get8148()) }
go/src/cmd/cgo/internal/test/issue8148.go/0
{ "file_path": "go/src/cmd/cgo/internal/test/issue8148.go", "repo_id": "go", "token_count": 173 }
73
// Copyright 2014 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build gc #include "textflag.h" TEXT cas<>(SB),NOSPLIT,$0 MOVW $0xffff0fc0, R15 // R15 is PC TEXT ·RewindAndSetgid(SB),NOSPLIT|NOFRAME,$0-0 // Save link register MOVW R14, R4 // Rewind stack pointer so anything that happens on the stack // will clobber the test pattern created by the caller ADD $(1024 * 8), R13 // Ask signaller to setgid MOVW $·Baton(SB), R2 storeloop: MOVW 0(R2), R0 MOVW $1, R1 BL cas<>(SB) BCC storeloop // Wait for setgid completion loop: MOVW $0, R0 MOVW $0, R1 BL cas<>(SB) BCC loop // Restore stack SUB $(1024 * 8), R13 MOVW R4, R14 RET
go/src/cmd/cgo/internal/test/issue9400/asm_arm.s/0
{ "file_path": "go/src/cmd/cgo/internal/test/issue9400/asm_arm.s", "repo_id": "go", "token_count": 328 }
74
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main /* #include <signal.h> #include <unistd.h> #include <stdlib.h> #include <stdio.h> // Raise SIGPIPE. static void CRaiseSIGPIPE() { int fds[2]; if (pipe(fds) == -1) { perror("pipe"); exit(EXIT_FAILURE); } // Close the reader end close(fds[0]); // Write to the writer end to provoke a SIGPIPE if (write(fds[1], "some data", 9) != -1) { fprintf(stderr, "write to a closed pipe succeeded\n"); exit(EXIT_FAILURE); } close(fds[1]); } */ import "C" import ( "fmt" "os" "runtime" ) // RunGoroutines starts some goroutines that don't do anything. // The idea is to get some threads going, so that a signal will be delivered // to a thread started by Go. // //export RunGoroutines func RunGoroutines() { for i := 0; i < 4; i++ { go func() { runtime.LockOSThread() select {} }() } } // Block blocks the current thread while running Go code. // //export Block func Block() { select {} } var P *byte // TestSEGV makes sure that an invalid address turns into a run-time Go panic. // //export TestSEGV func TestSEGV() { defer func() { if recover() == nil { fmt.Fprintln(os.Stderr, "no panic from segv") os.Exit(1) } }() *P = 0 fmt.Fprintln(os.Stderr, "continued after segv") os.Exit(1) } // Noop ensures that the Go runtime is initialized. // //export Noop func Noop() { } // Raise SIGPIPE. // //export GoRaiseSIGPIPE func GoRaiseSIGPIPE() { C.CRaiseSIGPIPE() } func main() { }
go/src/cmd/cgo/internal/testcarchive/testdata/libgo2/libgo2.go/0
{ "file_path": "go/src/cmd/cgo/internal/testcarchive/testdata/libgo2/libgo2.go", "repo_id": "go", "token_count": 644 }
75
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. #include <signal.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> struct sigaction sa; struct sigaction osa; static void (*oldHandler)(int, siginfo_t*, void*); static void handler(int signo, siginfo_t* info, void* ctxt) { if (oldHandler) { oldHandler(signo, info, ctxt); } } int install_handler() { // Install our own signal handler. memset(&sa, 0, sizeof sa); sa.sa_sigaction = handler; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_ONSTACK | SA_SIGINFO; memset(&osa, 0, sizeof osa); sigemptyset(&osa.sa_mask); if (sigaction(SIGSEGV, &sa, &osa) < 0) { perror("sigaction"); return 2; } if (osa.sa_handler == SIG_DFL) { fprintf(stderr, "Go runtime did not install signal handler\n"); return 2; } // gccgo does not set SA_ONSTACK for SIGSEGV. if (getenv("GCCGO") == NULL && (osa.sa_flags&SA_ONSTACK) == 0) { fprintf(stderr, "Go runtime did not install signal handler\n"); return 2; } oldHandler = osa.sa_sigaction; return 0; } int check_handler() { if (sigaction(SIGSEGV, NULL, &sa) < 0) { perror("sigaction check"); return 2; } if (sa.sa_sigaction != handler) { fprintf(stderr, "ERROR: wrong signal handler: %p != %p\n", sa.sa_sigaction, handler); return 2; } return 0; }
go/src/cmd/cgo/internal/testcarchive/testdata/main_unix.c/0
{ "file_path": "go/src/cmd/cgo/internal/testcarchive/testdata/main_unix.c", "repo_id": "go", "token_count": 573 }
76
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. #include <stdint.h> #include <stdio.h> #include <dlfcn.h> int check_int8(void* handle, const char* fname, int8_t want) { int8_t (*fn)(); fn = (int8_t (*)())dlsym(handle, fname); if (!fn) { fprintf(stderr, "ERROR: missing %s: %s\n", fname, dlerror()); return 1; } signed char ret = fn(); if (ret != want) { fprintf(stderr, "ERROR: %s=%d, want %d\n", fname, ret, want); return 1; } return 0; } int check_int32(void* handle, const char* fname, int32_t want) { int32_t (*fn)(); fn = (int32_t (*)())dlsym(handle, fname); if (!fn) { fprintf(stderr, "ERROR: missing %s: %s\n", fname, dlerror()); return 1; } int32_t ret = fn(); if (ret != want) { fprintf(stderr, "ERROR: %s=%d, want %d\n", fname, ret, want); return 1; } return 0; } // Tests libgo.so to export the following functions. // int8_t DidInitRun() // returns true // int8_t DidMainRun() // returns true // int32_t FromPkg() // returns 1024 int main(int argc, char** argv) { void* handle = dlopen(argv[1], RTLD_LAZY | RTLD_GLOBAL); if (!handle) { fprintf(stderr, "ERROR: failed to open the shared library: %s\n", dlerror()); return 2; } int ret = 0; ret = check_int8(handle, "DidInitRun", 1); if (ret != 0) { return ret; } ret = check_int8(handle, "DidMainRun", 0); if (ret != 0) { return ret; } ret = check_int32(handle, "FromPkg", 1024); if (ret != 0) { return ret; } // test.bash looks for "PASS" to ensure this program has reached the end. printf("PASS\n"); return 0; }
go/src/cmd/cgo/internal/testcshared/testdata/main1.c/0
{ "file_path": "go/src/cmd/cgo/internal/testcshared/testdata/main1.c", "repo_id": "go", "token_count": 717 }
77
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Issue 14669: test that fails when build with CGO_CFLAGS selecting // optimization. package p /* const int E = 1; typedef struct s { int c; } s; */ import "C" func F() { _ = C.s{ c: C.E, } }
go/src/cmd/cgo/internal/testerrors/testdata/issue14669.go/0
{ "file_path": "go/src/cmd/cgo/internal/testerrors/testdata/issue14669.go", "repo_id": "go", "token_count": 136 }
78
program HelloWorldF90 write(*,*) "Hello World!" end program HelloWorldF90
go/src/cmd/cgo/internal/testfortran/testdata/helloworld/helloworld.f90/0
{ "file_path": "go/src/cmd/cgo/internal/testfortran/testdata/helloworld/helloworld.f90", "repo_id": "go", "token_count": 45 }
79
// Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package cgolife // #include "life.h" import "C" import "unsafe" func Run(gen, x, y int, a []int32) { n := make([]int32, x*y) for i := 0; i < gen; i++ { C.Step(C.int(x), C.int(y), (*C.int)(unsafe.Pointer(&a[0])), (*C.int)(unsafe.Pointer(&n[0]))) copy(a, n) } } // Keep the channels visible from Go. var chans [4]chan bool // Double return value is just for testing. // //export GoStart func GoStart(i, xdim, ydim, xstart, xend, ystart, yend C.int, a *C.int, n *C.int) (int, int) { c := make(chan bool, int(C.MYCONST)) go func() { C.DoStep(xdim, ydim, xstart, xend, ystart, yend, a, n) c <- true }() chans[i] = c return int(i), int(i + 100) } //export GoWait func GoWait(i C.int) { <-chans[i] chans[i] = nil }
go/src/cmd/cgo/internal/testlife/testdata/life.go/0
{ "file_path": "go/src/cmd/cgo/internal/testlife/testdata/life.go", "repo_id": "go", "token_count": 387 }
80
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main import "plugin" func main() { p, err := plugin.Open("issue24351.so") if err != nil { panic(err) } f, err := p.Lookup("B") if err != nil { panic(err) } c := make(chan bool) f.(func(chan bool))(c) <-c }
go/src/cmd/cgo/internal/testplugin/testdata/issue24351/main.go/0
{ "file_path": "go/src/cmd/cgo/internal/testplugin/testdata/issue24351/main.go", "repo_id": "go", "token_count": 147 }
81
// Copyright 2017 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This test uses the Pdeathsig field of syscall.SysProcAttr, so it only works // on platforms that support that. //go:build linux || (freebsd && amd64) // sanitizers_test checks the use of Go with sanitizers like msan, asan, etc. // See https://github.com/google/sanitizers. package sanitizers_test import ( "bytes" "encoding/json" "errors" "fmt" "internal/testenv" "os" "os/exec" "os/user" "path/filepath" "regexp" "strconv" "strings" "sync" "syscall" "testing" "time" "unicode" ) var overcommit struct { sync.Once value int err error } // requireOvercommit skips t if the kernel does not allow overcommit. func requireOvercommit(t *testing.T) { t.Helper() overcommit.Once.Do(func() { var out []byte out, overcommit.err = os.ReadFile("/proc/sys/vm/overcommit_memory") if overcommit.err != nil { return } overcommit.value, overcommit.err = strconv.Atoi(string(bytes.TrimSpace(out))) }) if overcommit.err != nil { t.Skipf("couldn't determine vm.overcommit_memory (%v); assuming no overcommit", overcommit.err) } if overcommit.value == 2 { t.Skip("vm.overcommit_memory=2") } } var env struct { sync.Once m map[string]string err error } // goEnv returns the output of $(go env) as a map. func goEnv(key string) (string, error) { env.Once.Do(func() { var out []byte out, env.err = exec.Command("go", "env", "-json").Output() if env.err != nil { return } env.m = make(map[string]string) env.err = json.Unmarshal(out, &env.m) }) if env.err != nil { return "", env.err } v, ok := env.m[key] if !ok { return "", fmt.Errorf("`go env`: no entry for %v", key) } return v, nil } // replaceEnv sets the key environment variable to value in cmd. func replaceEnv(cmd *exec.Cmd, key, value string) { if cmd.Env == nil { cmd.Env = cmd.Environ() } cmd.Env = append(cmd.Env, key+"="+value) } // appendExperimentEnv appends comma-separated experiments to GOEXPERIMENT. func appendExperimentEnv(cmd *exec.Cmd, experiments []string) { if cmd.Env == nil { cmd.Env = cmd.Environ() } exps := strings.Join(experiments, ",") for _, evar := range cmd.Env { c := strings.SplitN(evar, "=", 2) if c[0] == "GOEXPERIMENT" { exps = c[1] + "," + exps } } cmd.Env = append(cmd.Env, "GOEXPERIMENT="+exps) } // mustRun executes t and fails cmd with a well-formatted message if it fails. func mustRun(t *testing.T, cmd *exec.Cmd) { t.Helper() out := new(strings.Builder) cmd.Stdout = out cmd.Stderr = out err := cmd.Start() if err != nil { t.Fatalf("%v: %v", cmd, err) } if deadline, ok := t.Deadline(); ok { timeout := time.Until(deadline) timeout -= timeout / 10 // Leave 10% headroom for logging and cleanup. timer := time.AfterFunc(timeout, func() { cmd.Process.Signal(syscall.SIGQUIT) }) defer timer.Stop() } if err := cmd.Wait(); err != nil { t.Fatalf("%v exited with %v\n%s", cmd, err, out) } } // cc returns a cmd that executes `$(go env CC) $(go env GOGCCFLAGS) $args`. func cc(args ...string) (*exec.Cmd, error) { CC, err := goEnv("CC") if err != nil { return nil, err } GOGCCFLAGS, err := goEnv("GOGCCFLAGS") if err != nil { return nil, err } // Split GOGCCFLAGS, respecting quoting. // // TODO(bcmills): This code also appears in // cmd/cgo/internal/testcarchive/carchive_test.go, and perhaps ought to go in // src/cmd/dist/test.go as well. Figure out where to put it so that it can be // shared. var flags []string quote := '\000' start := 0 lastSpace := true backslash := false for i, c := range GOGCCFLAGS { if quote == '\000' && unicode.IsSpace(c) { if !lastSpace { flags = append(flags, GOGCCFLAGS[start:i]) lastSpace = true } } else { if lastSpace { start = i lastSpace = false } if quote == '\000' && !backslash && (c == '"' || c == '\'') { quote = c backslash = false } else if !backslash && quote == c { quote = '\000' } else if (quote == '\000' || quote == '"') && !backslash && c == '\\' { backslash = true } else { backslash = false } } } if !lastSpace { flags = append(flags, GOGCCFLAGS[start:]) } cmd := exec.Command(CC, flags...) cmd.Args = append(cmd.Args, args...) return cmd, nil } type version struct { name string major, minor int } var compiler struct { sync.Once version err error } // compilerVersion detects the version of $(go env CC). // // It returns a non-nil error if the compiler matches a known version schema but // the version could not be parsed, or if $(go env CC) could not be determined. func compilerVersion() (version, error) { compiler.Once.Do(func() { compiler.err = func() error { compiler.name = "unknown" cmd, err := cc("--version") if err != nil { return err } out, err := cmd.Output() if err != nil { // Compiler does not support "--version" flag: not Clang or GCC. return nil } var match [][]byte if bytes.HasPrefix(out, []byte("gcc")) { compiler.name = "gcc" cmd, err := cc("-dumpfullversion", "-dumpversion") if err != nil { return err } out, err := cmd.Output() if err != nil { // gcc, but does not support gcc's "-v" flag?! return err } gccRE := regexp.MustCompile(`(\d+)\.(\d+)`) match = gccRE.FindSubmatch(out) } else { clangRE := regexp.MustCompile(`clang version (\d+)\.(\d+)`) if match = clangRE.FindSubmatch(out); len(match) > 0 { compiler.name = "clang" } } if len(match) < 3 { return nil // "unknown" } if compiler.major, err = strconv.Atoi(string(match[1])); err != nil { return err } if compiler.minor, err = strconv.Atoi(string(match[2])); err != nil { return err } return nil }() }) return compiler.version, compiler.err } // compilerSupportsLocation reports whether the compiler should be // able to provide file/line information in backtraces. func compilerSupportsLocation() bool { compiler, err := compilerVersion() if err != nil { return false } switch compiler.name { case "gcc": return compiler.major >= 10 case "clang": // TODO(65606): The clang toolchain on the LUCI builders is not built against // zlib, the ASAN runtime can't actually symbolize its own stack trace. Once // this is resolved, one way or another, switch this back to 'true'. We still // have coverage from the 'gcc' case above. if inLUCIBuild() { return false } return true default: return false } } // inLUCIBuild returns true if we're currently executing in a LUCI build. func inLUCIBuild() bool { u, err := user.Current() if err != nil { return false } return testenv.Builder() != "" && u.Username == "swarming" } // compilerRequiredTsanVersion reports whether the compiler is the version required by Tsan. // Only restrictions for ppc64le are known; otherwise return true. func compilerRequiredTsanVersion(goos, goarch string) bool { compiler, err := compilerVersion() if err != nil { return false } if compiler.name == "gcc" && goarch == "ppc64le" { return compiler.major >= 9 } return true } // compilerRequiredAsanVersion reports whether the compiler is the version required by Asan. func compilerRequiredAsanVersion(goos, goarch string) bool { compiler, err := compilerVersion() if err != nil { return false } switch compiler.name { case "gcc": if goarch == "loong64" { return compiler.major >= 14 } if goarch == "ppc64le" { return compiler.major >= 9 } return compiler.major >= 7 case "clang": if goarch == "loong64" { return compiler.major >= 16 } return compiler.major >= 9 default: return false } } type compilerCheck struct { once sync.Once err error skip bool // If true, skip with err instead of failing with it. } type config struct { sanitizer string cFlags, ldFlags, goFlags []string sanitizerCheck, runtimeCheck compilerCheck } var configs struct { sync.Mutex m map[string]*config } // configure returns the configuration for the given sanitizer. func configure(sanitizer string) *config { configs.Lock() defer configs.Unlock() if c, ok := configs.m[sanitizer]; ok { return c } c := &config{ sanitizer: sanitizer, cFlags: []string{"-fsanitize=" + sanitizer}, ldFlags: []string{"-fsanitize=" + sanitizer}, } if testing.Verbose() { c.goFlags = append(c.goFlags, "-x") } switch sanitizer { case "memory": c.goFlags = append(c.goFlags, "-msan") case "thread": c.goFlags = append(c.goFlags, "--installsuffix=tsan") compiler, _ := compilerVersion() if compiler.name == "gcc" { c.cFlags = append(c.cFlags, "-fPIC") c.ldFlags = append(c.ldFlags, "-fPIC", "-static-libtsan") } case "address": c.goFlags = append(c.goFlags, "-asan") // Set the debug mode to print the C stack trace. c.cFlags = append(c.cFlags, "-g") case "fuzzer": c.goFlags = append(c.goFlags, "-tags=libfuzzer", "-gcflags=-d=libfuzzer") default: panic(fmt.Sprintf("unrecognized sanitizer: %q", sanitizer)) } if configs.m == nil { configs.m = make(map[string]*config) } configs.m[sanitizer] = c return c } // goCmd returns a Cmd that executes "go $subcommand $args" with appropriate // additional flags and environment. func (c *config) goCmd(subcommand string, args ...string) *exec.Cmd { return c.goCmdWithExperiments(subcommand, args, nil) } // goCmdWithExperiments returns a Cmd that executes // "GOEXPERIMENT=$experiments go $subcommand $args" with appropriate // additional flags and CGO-related environment variables. func (c *config) goCmdWithExperiments(subcommand string, args []string, experiments []string) *exec.Cmd { cmd := exec.Command("go", subcommand) cmd.Args = append(cmd.Args, c.goFlags...) cmd.Args = append(cmd.Args, args...) replaceEnv(cmd, "CGO_CFLAGS", strings.Join(c.cFlags, " ")) replaceEnv(cmd, "CGO_LDFLAGS", strings.Join(c.ldFlags, " ")) appendExperimentEnv(cmd, experiments) return cmd } // skipIfCSanitizerBroken skips t if the C compiler does not produce working // binaries as configured. func (c *config) skipIfCSanitizerBroken(t *testing.T) { check := &c.sanitizerCheck check.once.Do(func() { check.skip, check.err = c.checkCSanitizer() }) if check.err != nil { t.Helper() if check.skip { t.Skip(check.err) } t.Fatal(check.err) } } var cMain = []byte(` int main() { return 0; } `) var cLibFuzzerInput = []byte(` #include <stddef.h> int LLVMFuzzerTestOneInput(char *data, size_t size) { return 0; } `) func (c *config) checkCSanitizer() (skip bool, err error) { dir, err := os.MkdirTemp("", c.sanitizer) if err != nil { return false, fmt.Errorf("failed to create temp directory: %v", err) } defer os.RemoveAll(dir) src := filepath.Join(dir, "return0.c") cInput := cMain if c.sanitizer == "fuzzer" { // libFuzzer generates the main function itself, and uses a different input. cInput = cLibFuzzerInput } if err := os.WriteFile(src, cInput, 0600); err != nil { return false, fmt.Errorf("failed to write C source file: %v", err) } dst := filepath.Join(dir, "return0") cmd, err := cc(c.cFlags...) if err != nil { return false, err } cmd.Args = append(cmd.Args, c.ldFlags...) cmd.Args = append(cmd.Args, "-o", dst, src) out, err := cmd.CombinedOutput() if err != nil { if bytes.Contains(out, []byte("-fsanitize")) && (bytes.Contains(out, []byte("unrecognized")) || bytes.Contains(out, []byte("unsupported"))) { return true, errors.New(string(out)) } return true, fmt.Errorf("%#q failed: %v\n%s", strings.Join(cmd.Args, " "), err, out) } if c.sanitizer == "fuzzer" { // For fuzzer, don't try running the test binary. It never finishes. return false, nil } if out, err := exec.Command(dst).CombinedOutput(); err != nil { if os.IsNotExist(err) { return true, fmt.Errorf("%#q failed to produce executable: %v", strings.Join(cmd.Args, " "), err) } snippet, _, _ := bytes.Cut(out, []byte("\n")) return true, fmt.Errorf("%#q generated broken executable: %v\n%s", strings.Join(cmd.Args, " "), err, snippet) } return false, nil } // skipIfRuntimeIncompatible skips t if the Go runtime is suspected not to work // with cgo as configured. func (c *config) skipIfRuntimeIncompatible(t *testing.T) { check := &c.runtimeCheck check.once.Do(func() { check.skip, check.err = c.checkRuntime() }) if check.err != nil { t.Helper() if check.skip { t.Skip(check.err) } t.Fatal(check.err) } } func (c *config) checkRuntime() (skip bool, err error) { if c.sanitizer != "thread" { return false, nil } // libcgo.h sets CGO_TSAN if it detects TSAN support in the C compiler. // Dump the preprocessor defines to check that works. // (Sometimes it doesn't: see https://golang.org/issue/15983.) cmd, err := cc(c.cFlags...) if err != nil { return false, err } cmd.Args = append(cmd.Args, "-dM", "-E", "../../../../runtime/cgo/libcgo.h") cmdStr := strings.Join(cmd.Args, " ") out, err := cmd.CombinedOutput() if err != nil { return false, fmt.Errorf("%#q exited with %v\n%s", cmdStr, err, out) } if !bytes.Contains(out, []byte("#define CGO_TSAN")) { return true, fmt.Errorf("%#q did not define CGO_TSAN", cmdStr) } return false, nil } // srcPath returns the path to the given file relative to this test's source tree. func srcPath(path string) string { return filepath.Join("testdata", path) } // A tempDir manages a temporary directory within a test. type tempDir struct { base string } func (d *tempDir) RemoveAll(t *testing.T) { t.Helper() if d.base == "" { return } if err := os.RemoveAll(d.base); err != nil { t.Fatalf("Failed to remove temp dir: %v", err) } } func (d *tempDir) Base() string { return d.base } func (d *tempDir) Join(name string) string { return filepath.Join(d.base, name) } func newTempDir(t *testing.T) *tempDir { t.Helper() dir, err := os.MkdirTemp("", filepath.Dir(t.Name())) if err != nil { t.Fatalf("Failed to create temp dir: %v", err) } return &tempDir{base: dir} } // hangProneCmd returns an exec.Cmd for a command that is likely to hang. // // If one of these tests hangs, the caller is likely to kill the test process // using SIGINT, which will be sent to all of the processes in the test's group. // Unfortunately, TSAN in particular is prone to dropping signals, so the SIGINT // may terminate the test binary but leave the subprocess running. hangProneCmd // configures subprocess to receive SIGKILL instead to ensure that it won't // leak. func hangProneCmd(name string, arg ...string) *exec.Cmd { cmd := exec.Command(name, arg...) cmd.SysProcAttr = &syscall.SysProcAttr{ Pdeathsig: syscall.SIGKILL, } return cmd }
go/src/cmd/cgo/internal/testsanitizers/cc_test.go/0
{ "file_path": "go/src/cmd/cgo/internal/testsanitizers/cc_test.go", "repo_id": "go", "token_count": 5688 }
82
package main import "cmd/cgo/internal/testsanitizers/testdata/asan_linkerx/p" func pstring(s *string) { println(*s) } func main() { all := []*string{ &S1, &S2, &S3, &S4, &S5, &S6, &S7, &S8, &S9, &S10, &p.S1, &p.S2, &p.S3, &p.S4, &p.S5, &p.S6, &p.S7, &p.S8, &p.S9, &p.S10, } for _, ps := range all { pstring(ps) } } var S1 string var S2 string var S3 string var S4 string var S5 string var S6 string var S7 string var S8 string var S9 string var S10 string
go/src/cmd/cgo/internal/testsanitizers/testdata/asan_linkerx/main.go/0
{ "file_path": "go/src/cmd/cgo/internal/testsanitizers/testdata/asan_linkerx/main.go", "repo_id": "go", "token_count": 247 }
83
// Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main // Test passing C struct to exported Go function. /* #include <stdint.h> #include <stdlib.h> // T is a C struct with alignment padding after b. // The padding bytes are not considered initialized by MSAN. // It is big enough to be passed on stack in C ABI (and least // on AMD64). typedef struct { char b; uintptr_t x, y; } T; extern void F(T); // Use weak as a hack to permit defining a function even though we use export. void CF(int x) __attribute__ ((weak)); void CF(int x) { T *t = malloc(sizeof(T)); t->b = (char)x; t->x = x; t->y = x; F(*t); } */ import "C" //export F func F(t C.T) { println(t.b, t.x, t.y) } func main() { C.CF(C.int(0)) }
go/src/cmd/cgo/internal/testsanitizers/testdata/msan7.go/0
{ "file_path": "go/src/cmd/cgo/internal/testsanitizers/testdata/msan7.go", "repo_id": "go", "token_count": 303 }
84
// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package main // Setting an environment variable in a cgo program changes the C // environment. Test that this does not confuse the race detector. /* #cgo CFLAGS: -fsanitize=thread #cgo LDFLAGS: -fsanitize=thread */ import "C" import ( "fmt" "os" "sync" "time" ) func main() { var wg sync.WaitGroup var mu sync.Mutex f := func() { defer wg.Done() for i := 0; i < 100; i++ { time.Sleep(time.Microsecond) mu.Lock() s := fmt.Sprint(i) os.Setenv("TSAN_TEST"+s, s) mu.Unlock() } } wg.Add(2) go f() go f() wg.Wait() }
go/src/cmd/cgo/internal/testsanitizers/testdata/tsan7.go/0
{ "file_path": "go/src/cmd/cgo/internal/testsanitizers/testdata/tsan7.go", "repo_id": "go", "token_count": 293 }
85
package main import "testshared/dep3" func main() { dep3.D3() }
go/src/cmd/cgo/internal/testshared/testdata/exe3/exe3.go/0
{ "file_path": "go/src/cmd/cgo/internal/testshared/testdata/exe3/exe3.go", "repo_id": "go", "token_count": 29 }
86
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package arm import ( "cmd/compile/internal/ssa" "cmd/compile/internal/ssagen" "cmd/internal/obj/arm" "internal/buildcfg" ) func Init(arch *ssagen.ArchInfo) { arch.LinkArch = &arm.Linkarm arch.REGSP = arm.REGSP arch.MAXWIDTH = (1 << 32) - 1 arch.SoftFloat = buildcfg.GOARM.SoftFloat arch.ZeroRange = zerorange arch.Ginsnop = ginsnop arch.SSAMarkMoves = func(s *ssagen.State, b *ssa.Block) {} arch.SSAGenValue = ssaGenValue arch.SSAGenBlock = ssaGenBlock }
go/src/cmd/compile/internal/arm/galign.go/0
{ "file_path": "go/src/cmd/compile/internal/arm/galign.go", "repo_id": "go", "token_count": 241 }
87
// Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package base import ( "fmt" "internal/buildcfg" "internal/types/errors" "os" "runtime/debug" "sort" "strings" "cmd/internal/src" "cmd/internal/telemetry/counter" ) // An errorMsg is a queued error message, waiting to be printed. type errorMsg struct { pos src.XPos msg string code errors.Code } // Pos is the current source position being processed, // printed by Errorf, ErrorfLang, Fatalf, and Warnf. var Pos src.XPos var ( errorMsgs []errorMsg numErrors int // number of entries in errorMsgs that are errors (as opposed to warnings) numSyntaxErrors int ) // Errors returns the number of errors reported. func Errors() int { return numErrors } // SyntaxErrors returns the number of syntax errors reported. func SyntaxErrors() int { return numSyntaxErrors } // addErrorMsg adds a new errorMsg (which may be a warning) to errorMsgs. func addErrorMsg(pos src.XPos, code errors.Code, format string, args ...interface{}) { msg := fmt.Sprintf(format, args...) // Only add the position if know the position. // See issue golang.org/issue/11361. if pos.IsKnown() { msg = fmt.Sprintf("%v: %s", FmtPos(pos), msg) } errorMsgs = append(errorMsgs, errorMsg{ pos: pos, msg: msg + "\n", code: code, }) } // FmtPos formats pos as a file:line string. func FmtPos(pos src.XPos) string { if Ctxt == nil { return "???" } return Ctxt.OutermostPos(pos).Format(Flag.C == 0, Flag.L == 1) } // byPos sorts errors by source position. type byPos []errorMsg func (x byPos) Len() int { return len(x) } func (x byPos) Less(i, j int) bool { return x[i].pos.Before(x[j].pos) } func (x byPos) Swap(i, j int) { x[i], x[j] = x[j], x[i] } // FlushErrors sorts errors seen so far by line number, prints them to stdout, // and empties the errors array. func FlushErrors() { if Ctxt != nil && Ctxt.Bso != nil { Ctxt.Bso.Flush() } if len(errorMsgs) == 0 { return } sort.Stable(byPos(errorMsgs)) for i, err := range errorMsgs { if i == 0 || err.msg != errorMsgs[i-1].msg { fmt.Print(err.msg) } } errorMsgs = errorMsgs[:0] } // lasterror keeps track of the most recently issued error, // to avoid printing multiple error messages on the same line. var lasterror struct { syntax src.XPos // source position of last syntax error other src.XPos // source position of last non-syntax error msg string // error message of last non-syntax error } // sameline reports whether two positions a, b are on the same line. func sameline(a, b src.XPos) bool { p := Ctxt.PosTable.Pos(a) q := Ctxt.PosTable.Pos(b) return p.Base() == q.Base() && p.Line() == q.Line() } // Errorf reports a formatted error at the current line. func Errorf(format string, args ...interface{}) { ErrorfAt(Pos, 0, format, args...) } // ErrorfAt reports a formatted error message at pos. func ErrorfAt(pos src.XPos, code errors.Code, format string, args ...interface{}) { msg := fmt.Sprintf(format, args...) if strings.HasPrefix(msg, "syntax error") { numSyntaxErrors++ // only one syntax error per line, no matter what error if sameline(lasterror.syntax, pos) { return } lasterror.syntax = pos } else { // only one of multiple equal non-syntax errors per line // (FlushErrors shows only one of them, so we filter them // here as best as we can (they may not appear in order) // so that we don't count them here and exit early, and // then have nothing to show for.) if sameline(lasterror.other, pos) && lasterror.msg == msg { return } lasterror.other = pos lasterror.msg = msg } addErrorMsg(pos, code, "%s", msg) numErrors++ hcrash() if numErrors >= 10 && Flag.LowerE == 0 { FlushErrors() fmt.Printf("%v: too many errors\n", FmtPos(pos)) ErrorExit() } } // UpdateErrorDot is a clumsy hack that rewrites the last error, // if it was "LINE: undefined: NAME", to be "LINE: undefined: NAME in EXPR". // It is used to give better error messages for dot (selector) expressions. func UpdateErrorDot(line string, name, expr string) { if len(errorMsgs) == 0 { return } e := &errorMsgs[len(errorMsgs)-1] if strings.HasPrefix(e.msg, line) && e.msg == fmt.Sprintf("%v: undefined: %v\n", line, name) { e.msg = fmt.Sprintf("%v: undefined: %v in %v\n", line, name, expr) } } // Warn reports a formatted warning at the current line. // In general the Go compiler does NOT generate warnings, // so this should be used only when the user has opted in // to additional output by setting a particular flag. func Warn(format string, args ...interface{}) { WarnfAt(Pos, format, args...) } // WarnfAt reports a formatted warning at pos. // In general the Go compiler does NOT generate warnings, // so this should be used only when the user has opted in // to additional output by setting a particular flag. func WarnfAt(pos src.XPos, format string, args ...interface{}) { addErrorMsg(pos, 0, format, args...) if Flag.LowerM != 0 { FlushErrors() } } // Fatalf reports a fatal error - an internal problem - at the current line and exits. // If other errors have already been printed, then Fatalf just quietly exits. // (The internal problem may have been caused by incomplete information // after the already-reported errors, so best to let users fix those and // try again without being bothered about a spurious internal error.) // // But if no errors have been printed, or if -d panic has been specified, // Fatalf prints the error as an "internal compiler error". In a released build, // it prints an error asking to file a bug report. In development builds, it // prints a stack trace. // // If -h has been specified, Fatalf panics to force the usual runtime info dump. func Fatalf(format string, args ...interface{}) { FatalfAt(Pos, format, args...) } var bugStack = counter.NewStack("compile/bug", 16) // 16 is arbitrary; used by gopls and crashmonitor // FatalfAt reports a fatal error - an internal problem - at pos and exits. // If other errors have already been printed, then FatalfAt just quietly exits. // (The internal problem may have been caused by incomplete information // after the already-reported errors, so best to let users fix those and // try again without being bothered about a spurious internal error.) // // But if no errors have been printed, or if -d panic has been specified, // FatalfAt prints the error as an "internal compiler error". In a released build, // it prints an error asking to file a bug report. In development builds, it // prints a stack trace. // // If -h has been specified, FatalfAt panics to force the usual runtime info dump. func FatalfAt(pos src.XPos, format string, args ...interface{}) { FlushErrors() bugStack.Inc() if Debug.Panic != 0 || numErrors == 0 { fmt.Printf("%v: internal compiler error: ", FmtPos(pos)) fmt.Printf(format, args...) fmt.Printf("\n") // If this is a released compiler version, ask for a bug report. if Debug.Panic == 0 && strings.HasPrefix(buildcfg.Version, "go") { fmt.Printf("\n") fmt.Printf("Please file a bug report including a short program that triggers the error.\n") fmt.Printf("https://go.dev/issue/new\n") } else { // Not a release; dump a stack trace, too. fmt.Println() os.Stdout.Write(debug.Stack()) fmt.Println() } } hcrash() ErrorExit() } // Assert reports "assertion failed" with Fatalf, unless b is true. func Assert(b bool) { if !b { Fatalf("assertion failed") } } // Assertf reports a fatal error with Fatalf, unless b is true. func Assertf(b bool, format string, args ...interface{}) { if !b { Fatalf(format, args...) } } // AssertfAt reports a fatal error with FatalfAt, unless b is true. func AssertfAt(b bool, pos src.XPos, format string, args ...interface{}) { if !b { FatalfAt(pos, format, args...) } } // hcrash crashes the compiler when -h is set, to find out where a message is generated. func hcrash() { if Flag.LowerH != 0 { FlushErrors() if Flag.LowerO != "" { os.Remove(Flag.LowerO) } panic("-h") } } // ErrorExit handles an error-status exit. // It flushes any pending errors, removes the output file, and exits. func ErrorExit() { FlushErrors() if Flag.LowerO != "" { os.Remove(Flag.LowerO) } os.Exit(2) } // ExitIfErrors calls ErrorExit if any errors have been reported. func ExitIfErrors() { if Errors() > 0 { ErrorExit() } } var AutogeneratedPos src.XPos
go/src/cmd/compile/internal/base/print.go/0
{ "file_path": "go/src/cmd/compile/internal/base/print.go", "repo_id": "go", "token_count": 2885 }
88
// Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package escape import ( "fmt" "cmd/compile/internal/base" "cmd/compile/internal/ir" "cmd/compile/internal/logopt" "cmd/compile/internal/typecheck" "cmd/compile/internal/types" "cmd/internal/src" ) // Escape analysis. // // Here we analyze functions to determine which Go variables // (including implicit allocations such as calls to "new" or "make", // composite literals, etc.) can be allocated on the stack. The two // key invariants we have to ensure are: (1) pointers to stack objects // cannot be stored in the heap, and (2) pointers to a stack object // cannot outlive that object (e.g., because the declaring function // returned and destroyed the object's stack frame, or its space is // reused across loop iterations for logically distinct variables). // // We implement this with a static data-flow analysis of the AST. // First, we construct a directed weighted graph where vertices // (termed "locations") represent variables allocated by statements // and expressions, and edges represent assignments between variables // (with weights representing addressing/dereference counts). // // Next we walk the graph looking for assignment paths that might // violate the invariants stated above. If a variable v's address is // stored in the heap or elsewhere that may outlive it, then v is // marked as requiring heap allocation. // // To support interprocedural analysis, we also record data-flow from // each function's parameters to the heap and to its result // parameters. This information is summarized as "parameter tags", // which are used at static call sites to improve escape analysis of // function arguments. // Constructing the location graph. // // Every allocating statement (e.g., variable declaration) or // expression (e.g., "new" or "make") is first mapped to a unique // "location." // // We also model every Go assignment as a directed edges between // locations. The number of dereference operations minus the number of // addressing operations is recorded as the edge's weight (termed // "derefs"). For example: // // p = &q // -1 // p = q // 0 // p = *q // 1 // p = **q // 2 // // p = **&**&q // 2 // // Note that the & operator can only be applied to addressable // expressions, and the expression &x itself is not addressable, so // derefs cannot go below -1. // // Every Go language construct is lowered into this representation, // generally without sensitivity to flow, path, or context; and // without distinguishing elements within a compound variable. For // example: // // var x struct { f, g *int } // var u []*int // // x.f = u[0] // // is modeled simply as // // x = *u // // That is, we don't distinguish x.f from x.g, or u[0] from u[1], // u[2], etc. However, we do record the implicit dereference involved // in indexing a slice. // A batch holds escape analysis state that's shared across an entire // batch of functions being analyzed at once. type batch struct { allLocs []*location closures []closure heapLoc location mutatorLoc location calleeLoc location blankLoc location } // A closure holds a closure expression and its spill hole (i.e., // where the hole representing storing into its closure record). type closure struct { k hole clo *ir.ClosureExpr } // An escape holds state specific to a single function being analyzed // within a batch. type escape struct { *batch curfn *ir.Func // function being analyzed labels map[*types.Sym]labelState // known labels // loopDepth counts the current loop nesting depth within // curfn. It increments within each "for" loop and at each // label with a corresponding backwards "goto" (i.e., // unstructured loop). loopDepth int } func Funcs(all []*ir.Func) { ir.VisitFuncsBottomUp(all, Batch) } // Batch performs escape analysis on a minimal batch of // functions. func Batch(fns []*ir.Func, recursive bool) { var b batch b.heapLoc.attrs = attrEscapes | attrPersists | attrMutates | attrCalls b.mutatorLoc.attrs = attrMutates b.calleeLoc.attrs = attrCalls // Construct data-flow graph from syntax trees. for _, fn := range fns { if base.Flag.W > 1 { s := fmt.Sprintf("\nbefore escape %v", fn) ir.Dump(s, fn) } b.initFunc(fn) } for _, fn := range fns { if !fn.IsClosure() { b.walkFunc(fn) } } // We've walked the function bodies, so we've seen everywhere a // variable might be reassigned or have it's address taken. Now we // can decide whether closures should capture their free variables // by value or reference. for _, closure := range b.closures { b.flowClosure(closure.k, closure.clo) } b.closures = nil for _, loc := range b.allLocs { if why := HeapAllocReason(loc.n); why != "" { b.flow(b.heapHole().addr(loc.n, why), loc) } } b.walkAll() b.finish(fns) } func (b *batch) with(fn *ir.Func) *escape { return &escape{ batch: b, curfn: fn, loopDepth: 1, } } func (b *batch) initFunc(fn *ir.Func) { e := b.with(fn) if fn.Esc() != escFuncUnknown { base.Fatalf("unexpected node: %v", fn) } fn.SetEsc(escFuncPlanned) if base.Flag.LowerM > 3 { ir.Dump("escAnalyze", fn) } // Allocate locations for local variables. for _, n := range fn.Dcl { e.newLoc(n, true) } // Also for hidden parameters (e.g., the ".this" parameter to a // method value wrapper). if fn.OClosure == nil { for _, n := range fn.ClosureVars { e.newLoc(n.Canonical(), true) } } // Initialize resultIndex for result parameters. for i, f := range fn.Type().Results() { e.oldLoc(f.Nname.(*ir.Name)).resultIndex = 1 + i } } func (b *batch) walkFunc(fn *ir.Func) { e := b.with(fn) fn.SetEsc(escFuncStarted) // Identify labels that mark the head of an unstructured loop. ir.Visit(fn, func(n ir.Node) { switch n.Op() { case ir.OLABEL: n := n.(*ir.LabelStmt) if n.Label.IsBlank() { break } if e.labels == nil { e.labels = make(map[*types.Sym]labelState) } e.labels[n.Label] = nonlooping case ir.OGOTO: // If we visited the label before the goto, // then this is a looping label. n := n.(*ir.BranchStmt) if e.labels[n.Label] == nonlooping { e.labels[n.Label] = looping } } }) e.block(fn.Body) if len(e.labels) != 0 { base.FatalfAt(fn.Pos(), "leftover labels after walkFunc") } } func (b *batch) flowClosure(k hole, clo *ir.ClosureExpr) { for _, cv := range clo.Func.ClosureVars { n := cv.Canonical() loc := b.oldLoc(cv) if !loc.captured { base.FatalfAt(cv.Pos(), "closure variable never captured: %v", cv) } // Capture by value for variables <= 128 bytes that are never reassigned. n.SetByval(!loc.addrtaken && !loc.reassigned && n.Type().Size() <= 128) if !n.Byval() { n.SetAddrtaken(true) if n.Sym().Name == typecheck.LocalDictName { base.FatalfAt(n.Pos(), "dictionary variable not captured by value") } } if base.Flag.LowerM > 1 { how := "ref" if n.Byval() { how = "value" } base.WarnfAt(n.Pos(), "%v capturing by %s: %v (addr=%v assign=%v width=%d)", n.Curfn, how, n, loc.addrtaken, loc.reassigned, n.Type().Size()) } // Flow captured variables to closure. k := k if !cv.Byval() { k = k.addr(cv, "reference") } b.flow(k.note(cv, "captured by a closure"), loc) } } func (b *batch) finish(fns []*ir.Func) { // Record parameter tags for package export data. for _, fn := range fns { fn.SetEsc(escFuncTagged) for i, param := range fn.Type().RecvParams() { param.Note = b.paramTag(fn, 1+i, param) } } for _, loc := range b.allLocs { n := loc.n if n == nil { continue } if n.Op() == ir.ONAME { n := n.(*ir.Name) n.Opt = nil } // Update n.Esc based on escape analysis results. // Omit escape diagnostics for go/defer wrappers, at least for now. // Historically, we haven't printed them, and test cases don't expect them. // TODO(mdempsky): Update tests to expect this. goDeferWrapper := n.Op() == ir.OCLOSURE && n.(*ir.ClosureExpr).Func.Wrapper() if loc.hasAttr(attrEscapes) { if n.Op() == ir.ONAME { if base.Flag.CompilingRuntime { base.ErrorfAt(n.Pos(), 0, "%v escapes to heap, not allowed in runtime", n) } if base.Flag.LowerM != 0 { base.WarnfAt(n.Pos(), "moved to heap: %v", n) } } else { if base.Flag.LowerM != 0 && !goDeferWrapper { base.WarnfAt(n.Pos(), "%v escapes to heap", n) } if logopt.Enabled() { var e_curfn *ir.Func // TODO(mdempsky): Fix. logopt.LogOpt(n.Pos(), "escape", "escape", ir.FuncName(e_curfn)) } } n.SetEsc(ir.EscHeap) } else { if base.Flag.LowerM != 0 && n.Op() != ir.ONAME && !goDeferWrapper { base.WarnfAt(n.Pos(), "%v does not escape", n) } n.SetEsc(ir.EscNone) if !loc.hasAttr(attrPersists) { switch n.Op() { case ir.OCLOSURE: n := n.(*ir.ClosureExpr) n.SetTransient(true) case ir.OMETHVALUE: n := n.(*ir.SelectorExpr) n.SetTransient(true) case ir.OSLICELIT: n := n.(*ir.CompLitExpr) n.SetTransient(true) } } } // If the result of a string->[]byte conversion is never mutated, // then it can simply reuse the string's memory directly. if base.Debug.ZeroCopy != 0 { if n, ok := n.(*ir.ConvExpr); ok && n.Op() == ir.OSTR2BYTES && !loc.hasAttr(attrMutates) { if base.Flag.LowerM >= 1 { base.WarnfAt(n.Pos(), "zero-copy string->[]byte conversion") } n.SetOp(ir.OSTR2BYTESTMP) } } } } // inMutualBatch reports whether function fn is in the batch of // mutually recursive functions being analyzed. When this is true, // fn has not yet been analyzed, so its parameters and results // should be incorporated directly into the flow graph instead of // relying on its escape analysis tagging. func (b *batch) inMutualBatch(fn *ir.Name) bool { if fn.Defn != nil && fn.Defn.Esc() < escFuncTagged { if fn.Defn.Esc() == escFuncUnknown { base.FatalfAt(fn.Pos(), "graph inconsistency: %v", fn) } return true } return false } const ( escFuncUnknown = 0 + iota escFuncPlanned escFuncStarted escFuncTagged ) // Mark labels that have no backjumps to them as not increasing e.loopdepth. type labelState int const ( looping labelState = 1 + iota nonlooping ) func (b *batch) paramTag(fn *ir.Func, narg int, f *types.Field) string { name := func() string { if f.Nname != nil { return f.Nname.Sym().Name } return fmt.Sprintf("arg#%d", narg) } // Only report diagnostics for user code; // not for wrappers generated around them. // TODO(mdempsky): Generalize this. diagnose := base.Flag.LowerM != 0 && !(fn.Wrapper() || fn.Dupok()) if len(fn.Body) == 0 { // Assume that uintptr arguments must be held live across the call. // This is most important for syscall.Syscall. // See golang.org/issue/13372. // This really doesn't have much to do with escape analysis per se, // but we are reusing the ability to annotate an individual function // argument and pass those annotations along to importing code. fn.Pragma |= ir.UintptrKeepAlive if f.Type.IsUintptr() { if diagnose { base.WarnfAt(f.Pos, "assuming %v is unsafe uintptr", name()) } return "" } if !f.Type.HasPointers() { // don't bother tagging for scalars return "" } var esc leaks // External functions are assumed unsafe, unless // //go:noescape is given before the declaration. if fn.Pragma&ir.Noescape != 0 { if diagnose && f.Sym != nil { base.WarnfAt(f.Pos, "%v does not escape", name()) } esc.AddMutator(0) esc.AddCallee(0) } else { if diagnose && f.Sym != nil { base.WarnfAt(f.Pos, "leaking param: %v", name()) } esc.AddHeap(0) } return esc.Encode() } if fn.Pragma&ir.UintptrEscapes != 0 { if f.Type.IsUintptr() { if diagnose { base.WarnfAt(f.Pos, "marking %v as escaping uintptr", name()) } return "" } if f.IsDDD() && f.Type.Elem().IsUintptr() { // final argument is ...uintptr. if diagnose { base.WarnfAt(f.Pos, "marking %v as escaping ...uintptr", name()) } return "" } } if !f.Type.HasPointers() { // don't bother tagging for scalars return "" } // Unnamed parameters are unused and therefore do not escape. if f.Sym == nil || f.Sym.IsBlank() { var esc leaks return esc.Encode() } n := f.Nname.(*ir.Name) loc := b.oldLoc(n) esc := loc.paramEsc esc.Optimize() if diagnose && !loc.hasAttr(attrEscapes) { b.reportLeaks(f.Pos, name(), esc, fn.Type()) } return esc.Encode() } func (b *batch) reportLeaks(pos src.XPos, name string, esc leaks, sig *types.Type) { warned := false if x := esc.Heap(); x >= 0 { if x == 0 { base.WarnfAt(pos, "leaking param: %v", name) } else { // TODO(mdempsky): Mention level=x like below? base.WarnfAt(pos, "leaking param content: %v", name) } warned = true } for i := 0; i < numEscResults; i++ { if x := esc.Result(i); x >= 0 { res := sig.Result(i).Nname.Sym().Name base.WarnfAt(pos, "leaking param: %v to result %v level=%d", name, res, x) warned = true } } if base.Debug.EscapeMutationsCalls <= 0 { if !warned { base.WarnfAt(pos, "%v does not escape", name) } return } if x := esc.Mutator(); x >= 0 { base.WarnfAt(pos, "mutates param: %v derefs=%v", name, x) warned = true } if x := esc.Callee(); x >= 0 { base.WarnfAt(pos, "calls param: %v derefs=%v", name, x) warned = true } if !warned { base.WarnfAt(pos, "%v does not escape, mutate, or call", name) } }
go/src/cmd/compile/internal/escape/escape.go/0
{ "file_path": "go/src/cmd/compile/internal/escape/escape.go", "repo_id": "go", "token_count": 5252 }
89
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // This file implements support functionality for iimport.go. package importer import ( "cmd/compile/internal/base" "cmd/compile/internal/types2" "fmt" "go/token" "internal/pkgbits" "sync" ) func assert(p bool) { base.Assert(p) } func errorf(format string, args ...interface{}) { panic(fmt.Sprintf(format, args...)) } const deltaNewFile = -64 // see cmd/compile/internal/gc/bexport.go // Synthesize a token.Pos type fakeFileSet struct { fset *token.FileSet files map[string]*token.File } func (s *fakeFileSet) pos(file string, line, column int) token.Pos { // TODO(mdempsky): Make use of column. // Since we don't know the set of needed file positions, we // reserve maxlines positions per file. const maxlines = 64 * 1024 f := s.files[file] if f == nil { f = s.fset.AddFile(file, -1, maxlines) s.files[file] = f // Allocate the fake linebreak indices on first use. // TODO(adonovan): opt: save ~512KB using a more complex scheme? fakeLinesOnce.Do(func() { fakeLines = make([]int, maxlines) for i := range fakeLines { fakeLines[i] = i } }) f.SetLines(fakeLines) } if line > maxlines { line = 1 } // Treat the file as if it contained only newlines // and column=1: use the line number as the offset. return f.Pos(line - 1) } var ( fakeLines []int fakeLinesOnce sync.Once ) func chanDir(d int) types2.ChanDir { // tag values must match the constants in cmd/compile/internal/gc/go.go switch d { case 1 /* Crecv */ : return types2.RecvOnly case 2 /* Csend */ : return types2.SendOnly case 3 /* Cboth */ : return types2.SendRecv default: errorf("unexpected channel dir %d", d) return 0 } } var predeclared = []types2.Type{ // basic types types2.Typ[types2.Bool], types2.Typ[types2.Int], types2.Typ[types2.Int8], types2.Typ[types2.Int16], types2.Typ[types2.Int32], types2.Typ[types2.Int64], types2.Typ[types2.Uint], types2.Typ[types2.Uint8], types2.Typ[types2.Uint16], types2.Typ[types2.Uint32], types2.Typ[types2.Uint64], types2.Typ[types2.Uintptr], types2.Typ[types2.Float32], types2.Typ[types2.Float64], types2.Typ[types2.Complex64], types2.Typ[types2.Complex128], types2.Typ[types2.String], // basic type aliases types2.Universe.Lookup("byte").Type(), types2.Universe.Lookup("rune").Type(), // error types2.Universe.Lookup("error").Type(), // untyped types types2.Typ[types2.UntypedBool], types2.Typ[types2.UntypedInt], types2.Typ[types2.UntypedRune], types2.Typ[types2.UntypedFloat], types2.Typ[types2.UntypedComplex], types2.Typ[types2.UntypedString], types2.Typ[types2.UntypedNil], // package unsafe types2.Typ[types2.UnsafePointer], // invalid type types2.Typ[types2.Invalid], // only appears in packages with errors // used internally by gc; never used by this package or in .a files // not to be confused with the universe any anyType{}, // comparable types2.Universe.Lookup("comparable").Type(), // "any" has special handling: see usage of predeclared. } type anyType struct{} func (t anyType) Underlying() types2.Type { return t } func (t anyType) String() string { return "any" } // See cmd/compile/internal/noder.derivedInfo. type derivedInfo struct { idx pkgbits.Index needed bool } // See cmd/compile/internal/noder.typeInfo. type typeInfo struct { idx pkgbits.Index derived bool }
go/src/cmd/compile/internal/importer/support.go/0
{ "file_path": "go/src/cmd/compile/internal/importer/support.go", "repo_id": "go", "token_count": 1358 }
90
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package inlheur import ( "cmd/compile/internal/base" "cmd/compile/internal/ir" "cmd/compile/internal/types" "fmt" "os" ) // funcFlagsAnalyzer computes the "Flags" value for the FuncProps // object we're computing. The main item of interest here is "nstate", // which stores the disposition of a given ir Node with respect to the // flags/properties we're trying to compute. type funcFlagsAnalyzer struct { fn *ir.Func nstate map[ir.Node]pstate noInfo bool // set if we see something inscrutable/un-analyzable } // pstate keeps track of the disposition of a given node and its // children with respect to panic/exit calls. type pstate int const ( psNoInfo pstate = iota // nothing interesting about this node psCallsPanic // node causes call to panic or os.Exit psMayReturn // executing node may trigger a "return" stmt psTop // dataflow lattice "top" element ) func makeFuncFlagsAnalyzer(fn *ir.Func) *funcFlagsAnalyzer { return &funcFlagsAnalyzer{ fn: fn, nstate: make(map[ir.Node]pstate), } } // setResults transfers func flag results to 'funcProps'. func (ffa *funcFlagsAnalyzer) setResults(funcProps *FuncProps) { var rv FuncPropBits if !ffa.noInfo && ffa.stateForList(ffa.fn.Body) == psCallsPanic { rv = FuncPropNeverReturns } // This is slightly hacky and not at all required, but include a // special case for main.main, which often ends in a call to // os.Exit. People who write code like this (very common I // imagine) // // func main() { // rc = perform() // ... // foo() // os.Exit(rc) // } // // will be constantly surprised when foo() is inlined in many // other spots in the program but not in main(). if isMainMain(ffa.fn) { rv &^= FuncPropNeverReturns } funcProps.Flags = rv } func (ffa *funcFlagsAnalyzer) getState(n ir.Node) pstate { return ffa.nstate[n] } func (ffa *funcFlagsAnalyzer) setState(n ir.Node, st pstate) { if st != psNoInfo { ffa.nstate[n] = st } } func (ffa *funcFlagsAnalyzer) updateState(n ir.Node, st pstate) { if st == psNoInfo { delete(ffa.nstate, n) } else { ffa.nstate[n] = st } } func (ffa *funcFlagsAnalyzer) panicPathTable() map[ir.Node]pstate { return ffa.nstate } // blockCombine merges together states as part of a linear sequence of // statements, where 'pred' and 'succ' are analysis results for a pair // of consecutive statements. Examples: // // case 1: case 2: // panic("foo") if q { return x } <-pred // return x panic("boo") <-succ // // In case 1, since the pred state is "always panic" it doesn't matter // what the succ state is, hence the state for the combination of the // two blocks is "always panics". In case 2, because there is a path // to return that avoids the panic in succ, the state for the // combination of the two statements is "may return". func blockCombine(pred, succ pstate) pstate { switch succ { case psTop: return pred case psMayReturn: if pred == psCallsPanic { return psCallsPanic } return psMayReturn case psNoInfo: return pred case psCallsPanic: if pred == psMayReturn { return psMayReturn } return psCallsPanic } panic("should never execute") } // branchCombine combines two states at a control flow branch point where // either p1 or p2 executes (as in an "if" statement). func branchCombine(p1, p2 pstate) pstate { if p1 == psCallsPanic && p2 == psCallsPanic { return psCallsPanic } if p1 == psMayReturn || p2 == psMayReturn { return psMayReturn } return psNoInfo } // stateForList walks through a list of statements and computes the // state/disposition for the entire list as a whole, as well // as updating disposition of intermediate nodes. func (ffa *funcFlagsAnalyzer) stateForList(list ir.Nodes) pstate { st := psTop // Walk the list backwards so that we can update the state for // earlier list elements based on what we find out about their // successors. Example: // // if ... { // L10: foo() // L11: <stmt> // L12: panic(...) // } // // After combining the dispositions for line 11 and 12, we want to // update the state for the call at line 10 based on that combined // disposition (if L11 has no path to "return", then the call at // line 10 will be on a panic path). for i := len(list) - 1; i >= 0; i-- { n := list[i] psi := ffa.getState(n) if debugTrace&debugTraceFuncFlags != 0 { fmt.Fprintf(os.Stderr, "=-= %v: stateForList n=%s ps=%s\n", ir.Line(n), n.Op().String(), psi.String()) } st = blockCombine(psi, st) ffa.updateState(n, st) } if st == psTop { st = psNoInfo } return st } func isMainMain(fn *ir.Func) bool { s := fn.Sym() return (s.Pkg.Name == "main" && s.Name == "main") } func isWellKnownFunc(s *types.Sym, pkg, name string) bool { return s.Pkg.Path == pkg && s.Name == name } // isExitCall reports TRUE if the node itself is an unconditional // call to os.Exit(), a panic, or a function that does likewise. func isExitCall(n ir.Node) bool { if n.Op() != ir.OCALLFUNC { return false } cx := n.(*ir.CallExpr) name := ir.StaticCalleeName(cx.Fun) if name == nil { return false } s := name.Sym() if isWellKnownFunc(s, "os", "Exit") || isWellKnownFunc(s, "runtime", "throw") { return true } if funcProps := propsForFunc(name.Func); funcProps != nil { if funcProps.Flags&FuncPropNeverReturns != 0 { return true } } return name.Func.NeverReturns() } // pessimize is called to record the fact that we saw something in the // function that renders it entirely impossible to analyze. func (ffa *funcFlagsAnalyzer) pessimize() { ffa.noInfo = true } // shouldVisit reports TRUE if this is an interesting node from the // perspective of computing function flags. NB: due to the fact that // ir.CallExpr implements the Stmt interface, we wind up visiting // a lot of nodes that we don't really need to, but these can // simply be screened out as part of the visit. func shouldVisit(n ir.Node) bool { _, isStmt := n.(ir.Stmt) return n.Op() != ir.ODCL && (isStmt || n.Op() == ir.OCALLFUNC || n.Op() == ir.OPANIC) } // nodeVisitPost helps implement the propAnalyzer interface; when // called on a given node, it decides the disposition of that node // based on the state(s) of the node's children. func (ffa *funcFlagsAnalyzer) nodeVisitPost(n ir.Node) { if debugTrace&debugTraceFuncFlags != 0 { fmt.Fprintf(os.Stderr, "=+= nodevis %v %s should=%v\n", ir.Line(n), n.Op().String(), shouldVisit(n)) } if !shouldVisit(n) { return } var st pstate switch n.Op() { case ir.OCALLFUNC: if isExitCall(n) { st = psCallsPanic } case ir.OPANIC: st = psCallsPanic case ir.ORETURN: st = psMayReturn case ir.OBREAK, ir.OCONTINUE: // FIXME: this handling of break/continue is sub-optimal; we // have them as "mayReturn" in order to help with this case: // // for { // if q() { break } // panic(...) // } // // where the effect of the 'break' is to cause the subsequent // panic to be skipped. One possible improvement would be to // track whether the currently enclosing loop is a "for {" or // a for/range with condition, then use mayReturn only for the // former. Note also that "break X" or "continue X" is treated // the same as "goto", since we don't have a good way to track // the target of the branch. st = psMayReturn n := n.(*ir.BranchStmt) if n.Label != nil { ffa.pessimize() } case ir.OBLOCK: n := n.(*ir.BlockStmt) st = ffa.stateForList(n.List) case ir.OCASE: if ccst, ok := n.(*ir.CaseClause); ok { st = ffa.stateForList(ccst.Body) } else if ccst, ok := n.(*ir.CommClause); ok { st = ffa.stateForList(ccst.Body) } else { panic("unexpected") } case ir.OIF: n := n.(*ir.IfStmt) st = branchCombine(ffa.stateForList(n.Body), ffa.stateForList(n.Else)) case ir.OFOR: // Treat for { XXX } like a block. // Treat for <cond> { XXX } like an if statement with no else. n := n.(*ir.ForStmt) bst := ffa.stateForList(n.Body) if n.Cond == nil { st = bst } else { if bst == psMayReturn { st = psMayReturn } } case ir.ORANGE: // Treat for range { XXX } like an if statement with no else. n := n.(*ir.RangeStmt) if ffa.stateForList(n.Body) == psMayReturn { st = psMayReturn } case ir.OGOTO: // punt if we see even one goto. if we built a control // flow graph we could do more, but this is just a tree walk. ffa.pessimize() case ir.OSELECT: // process selects for "may return" but not "always panics", // the latter case seems very improbable. n := n.(*ir.SelectStmt) if len(n.Cases) != 0 { st = psTop for _, c := range n.Cases { st = branchCombine(ffa.stateForList(c.Body), st) } } case ir.OSWITCH: n := n.(*ir.SwitchStmt) if len(n.Cases) != 0 { st = psTop for _, c := range n.Cases { st = branchCombine(ffa.stateForList(c.Body), st) } } st, fall := psTop, psNoInfo for i := len(n.Cases) - 1; i >= 0; i-- { cas := n.Cases[i] cst := ffa.stateForList(cas.Body) endsInFallthrough := false if len(cas.Body) != 0 { endsInFallthrough = cas.Body[0].Op() == ir.OFALL } if endsInFallthrough { cst = blockCombine(cst, fall) } st = branchCombine(st, cst) fall = cst } case ir.OFALL: // Not important. case ir.ODCLFUNC, ir.ORECOVER, ir.OAS, ir.OAS2, ir.OAS2FUNC, ir.OASOP, ir.OPRINTLN, ir.OPRINT, ir.OLABEL, ir.OCALLINTER, ir.ODEFER, ir.OSEND, ir.ORECV, ir.OSELRECV2, ir.OGO, ir.OAPPEND, ir.OAS2DOTTYPE, ir.OAS2MAPR, ir.OGETG, ir.ODELETE, ir.OINLMARK, ir.OAS2RECV, ir.OMIN, ir.OMAX, ir.OMAKE, ir.ORECOVERFP, ir.OGETCALLERSP: // these should all be benign/uninteresting case ir.OTAILCALL, ir.OJUMPTABLE, ir.OTYPESW: // don't expect to see these at all. base.Fatalf("unexpected op %s in func %s", n.Op().String(), ir.FuncName(ffa.fn)) default: base.Fatalf("%v: unhandled op %s in func %v", ir.Line(n), n.Op().String(), ir.FuncName(ffa.fn)) } if debugTrace&debugTraceFuncFlags != 0 { fmt.Fprintf(os.Stderr, "=-= %v: visit n=%s returns %s\n", ir.Line(n), n.Op().String(), st.String()) } ffa.setState(n, st) } func (ffa *funcFlagsAnalyzer) nodeVisitPre(n ir.Node) { }
go/src/cmd/compile/internal/inline/inlheur/analyze_func_flags.go/0
{ "file_path": "go/src/cmd/compile/internal/inline/inlheur/analyze_func_flags.go", "repo_id": "go", "token_count": 4136 }
91
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package inlheur import ( "cmd/compile/internal/ir" "fmt" "os" ) // This file contains code to re-score callsites based on how the // results of the call were used. Example: // // func foo() { // x, fptr := bar() // switch x { // case 10: fptr = baz() // default: blix() // } // fptr(100) // } // // The initial scoring pass will assign a score to "bar()" based on // various criteria, however once the first pass of scoring is done, // we look at the flags on the result from bar, and check to see // how those results are used. If bar() always returns the same constant // for its first result, and if the variable receiving that result // isn't redefined, and if that variable feeds into an if/switch // condition, then we will try to adjust the score for "bar" (on the // theory that if we inlined, we can constant fold / deadcode). type resultPropAndCS struct { defcs *CallSite props ResultPropBits } type resultUseAnalyzer struct { resultNameTab map[*ir.Name]resultPropAndCS fn *ir.Func cstab CallSiteTab *condLevelTracker } // rescoreBasedOnCallResultUses examines how call results are used, // and tries to update the scores of calls based on how their results // are used in the function. func (csa *callSiteAnalyzer) rescoreBasedOnCallResultUses(fn *ir.Func, resultNameTab map[*ir.Name]resultPropAndCS, cstab CallSiteTab) { enableDebugTraceIfEnv() rua := &resultUseAnalyzer{ resultNameTab: resultNameTab, fn: fn, cstab: cstab, condLevelTracker: new(condLevelTracker), } var doNode func(ir.Node) bool doNode = func(n ir.Node) bool { rua.nodeVisitPre(n) ir.DoChildren(n, doNode) rua.nodeVisitPost(n) return false } doNode(fn) disableDebugTrace() } func (csa *callSiteAnalyzer) examineCallResults(cs *CallSite, resultNameTab map[*ir.Name]resultPropAndCS) map[*ir.Name]resultPropAndCS { if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= examining call results for %q\n", EncodeCallSiteKey(cs)) } // Invoke a helper to pick out the specific ir.Name's the results // from this call are assigned into, e.g. "x, y := fooBar()". If // the call is not part of an assignment statement, or if the // variables in question are not newly defined, then we'll receive // an empty list here. // names, autoTemps, props := namesDefined(cs) if len(names) == 0 { return resultNameTab } if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= %d names defined\n", len(names)) } // For each returned value, if the value has interesting // properties (ex: always returns the same constant), and the name // in question is never redefined, then make an entry in the // result table for it. const interesting = (ResultIsConcreteTypeConvertedToInterface | ResultAlwaysSameConstant | ResultAlwaysSameInlinableFunc | ResultAlwaysSameFunc) for idx, n := range names { rprop := props.ResultFlags[idx] if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= props for ret %d %q: %s\n", idx, n.Sym().Name, rprop.String()) } if rprop&interesting == 0 { continue } if csa.nameFinder.reassigned(n) { continue } if resultNameTab == nil { resultNameTab = make(map[*ir.Name]resultPropAndCS) } else if _, ok := resultNameTab[n]; ok { panic("should never happen") } entry := resultPropAndCS{ defcs: cs, props: rprop, } resultNameTab[n] = entry if autoTemps[idx] != nil { resultNameTab[autoTemps[idx]] = entry } if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= add resultNameTab table entry n=%v autotemp=%v props=%s\n", n, autoTemps[idx], rprop.String()) } } return resultNameTab } // namesDefined returns a list of ir.Name's corresponding to locals // that receive the results from the call at site 'cs', plus the // properties object for the called function. If a given result // isn't cleanly assigned to a newly defined local, the // slot for that result in the returned list will be nil. Example: // // call returned name list // // x := foo() [ x ] // z, y := bar() [ nil, nil ] // _, q := baz() [ nil, q ] // // In the case of a multi-return call, such as "x, y := foo()", // the pattern we see from the front end will be a call op // assigning to auto-temps, and then an assignment of the auto-temps // to the user-level variables. In such cases we return // first the user-level variable (in the first func result) // and then the auto-temp name in the second result. func namesDefined(cs *CallSite) ([]*ir.Name, []*ir.Name, *FuncProps) { // If this call doesn't feed into an assignment (and of course not // all calls do), then we don't have anything to work with here. if cs.Assign == nil { return nil, nil, nil } funcInlHeur, ok := fpmap[cs.Callee] if !ok { // TODO: add an assert/panic here. return nil, nil, nil } if len(funcInlHeur.props.ResultFlags) == 0 { return nil, nil, nil } // Single return case. if len(funcInlHeur.props.ResultFlags) == 1 { asgn, ok := cs.Assign.(*ir.AssignStmt) if !ok { return nil, nil, nil } // locate name being assigned aname, ok := asgn.X.(*ir.Name) if !ok { return nil, nil, nil } return []*ir.Name{aname}, []*ir.Name{nil}, funcInlHeur.props } // Multi-return case asgn, ok := cs.Assign.(*ir.AssignListStmt) if !ok || !asgn.Def { return nil, nil, nil } userVars := make([]*ir.Name, len(funcInlHeur.props.ResultFlags)) autoTemps := make([]*ir.Name, len(funcInlHeur.props.ResultFlags)) for idx, x := range asgn.Lhs { if n, ok := x.(*ir.Name); ok { userVars[idx] = n r := asgn.Rhs[idx] if r.Op() == ir.OCONVNOP { r = r.(*ir.ConvExpr).X } if ir.IsAutoTmp(r) { autoTemps[idx] = r.(*ir.Name) } if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= multi-ret namedef uv=%v at=%v\n", x, autoTemps[idx]) } } else { return nil, nil, nil } } return userVars, autoTemps, funcInlHeur.props } func (rua *resultUseAnalyzer) nodeVisitPost(n ir.Node) { rua.condLevelTracker.post(n) } func (rua *resultUseAnalyzer) nodeVisitPre(n ir.Node) { rua.condLevelTracker.pre(n) switch n.Op() { case ir.OCALLINTER: if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= rescore examine iface call %v:\n", n) } rua.callTargetCheckResults(n) case ir.OCALLFUNC: if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= rescore examine call %v:\n", n) } rua.callTargetCheckResults(n) case ir.OIF: ifst := n.(*ir.IfStmt) rua.foldCheckResults(ifst.Cond) case ir.OSWITCH: swst := n.(*ir.SwitchStmt) if swst.Tag != nil { rua.foldCheckResults(swst.Tag) } } } // callTargetCheckResults examines a given call to see whether the // callee expression is potentially an inlinable function returned // from a potentially inlinable call. Examples: // // Scenario 1: named intermediate // // fn1 := foo() conc := bar() // fn1("blah") conc.MyMethod() // // Scenario 2: returned func or concrete object feeds directly to call // // foo()("blah") bar().MyMethod() // // In the second case although at the source level the result of the // direct call feeds right into the method call or indirect call, // we're relying on the front end having inserted an auto-temp to // capture the value. func (rua *resultUseAnalyzer) callTargetCheckResults(call ir.Node) { ce := call.(*ir.CallExpr) rname := rua.getCallResultName(ce) if rname == nil { return } if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= staticvalue returns %v:\n", rname) } if rname.Class != ir.PAUTO { return } switch call.Op() { case ir.OCALLINTER: if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= in %s checking %v for cci prop:\n", rua.fn.Sym().Name, rname) } if cs := rua.returnHasProp(rname, ResultIsConcreteTypeConvertedToInterface); cs != nil { adj := returnFeedsConcreteToInterfaceCallAdj cs.Score, cs.ScoreMask = adjustScore(adj, cs.Score, cs.ScoreMask) } case ir.OCALLFUNC: if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= in %s checking %v for samefunc props:\n", rua.fn.Sym().Name, rname) v, ok := rua.resultNameTab[rname] if !ok { fmt.Fprintf(os.Stderr, "=-= no entry for %v in rt\n", rname) } else { fmt.Fprintf(os.Stderr, "=-= props for %v: %q\n", rname, v.props.String()) } } if cs := rua.returnHasProp(rname, ResultAlwaysSameInlinableFunc); cs != nil { adj := returnFeedsInlinableFuncToIndCallAdj cs.Score, cs.ScoreMask = adjustScore(adj, cs.Score, cs.ScoreMask) } else if cs := rua.returnHasProp(rname, ResultAlwaysSameFunc); cs != nil { adj := returnFeedsFuncToIndCallAdj cs.Score, cs.ScoreMask = adjustScore(adj, cs.Score, cs.ScoreMask) } } } // foldCheckResults examines the specified if/switch condition 'cond' // to see if it refers to locals defined by a (potentially inlinable) // function call at call site C, and if so, whether 'cond' contains // only combinations of simple references to all of the names in // 'names' with selected constants + operators. If these criteria are // met, then we adjust the score for call site C to reflect the // fact that inlining will enable deadcode and/or constant propagation. // Note: for this heuristic to kick in, the names in question have to // be all from the same callsite. Examples: // // q, r := baz() x, y := foo() // switch q+r { a, b, c := bar() // ... if x && y && a && b && c { // } ... // } // // For the call to "baz" above we apply a score adjustment, but not // for the calls to "foo" or "bar". func (rua *resultUseAnalyzer) foldCheckResults(cond ir.Node) { namesUsed := collectNamesUsed(cond) if len(namesUsed) == 0 { return } var cs *CallSite for _, n := range namesUsed { rpcs, found := rua.resultNameTab[n] if !found { return } if cs != nil && rpcs.defcs != cs { return } cs = rpcs.defcs if rpcs.props&ResultAlwaysSameConstant == 0 { return } } if debugTrace&debugTraceScoring != 0 { nls := func(nl []*ir.Name) string { r := "" for _, n := range nl { r += " " + n.Sym().Name } return r } fmt.Fprintf(os.Stderr, "=-= calling ShouldFoldIfNameConstant on names={%s} cond=%v\n", nls(namesUsed), cond) } if !ShouldFoldIfNameConstant(cond, namesUsed) { return } adj := returnFeedsConstToIfAdj cs.Score, cs.ScoreMask = adjustScore(adj, cs.Score, cs.ScoreMask) } func collectNamesUsed(expr ir.Node) []*ir.Name { res := []*ir.Name{} ir.Visit(expr, func(n ir.Node) { if n.Op() != ir.ONAME { return } nn := n.(*ir.Name) if nn.Class != ir.PAUTO { return } res = append(res, nn) }) return res } func (rua *resultUseAnalyzer) returnHasProp(name *ir.Name, prop ResultPropBits) *CallSite { v, ok := rua.resultNameTab[name] if !ok { return nil } if v.props&prop == 0 { return nil } return v.defcs } func (rua *resultUseAnalyzer) getCallResultName(ce *ir.CallExpr) *ir.Name { var callTarg ir.Node if sel, ok := ce.Fun.(*ir.SelectorExpr); ok { // method call callTarg = sel.X } else if ctarg, ok := ce.Fun.(*ir.Name); ok { // regular call callTarg = ctarg } else { return nil } r := ir.StaticValue(callTarg) if debugTrace&debugTraceScoring != 0 { fmt.Fprintf(os.Stderr, "=-= staticname on %v returns %v:\n", callTarg, r) } if r.Op() == ir.OCALLFUNC { // This corresponds to the "x := foo()" case; here // ir.StaticValue has brought us all the way back to // the call expression itself. We need to back off to // the name defined by the call; do this by looking up // the callsite. ce := r.(*ir.CallExpr) cs, ok := rua.cstab[ce] if !ok { return nil } names, _, _ := namesDefined(cs) if len(names) == 0 { return nil } return names[0] } else if r.Op() == ir.ONAME { return r.(*ir.Name) } return nil }
go/src/cmd/compile/internal/inline/inlheur/score_callresult_uses.go/0
{ "file_path": "go/src/cmd/compile/internal/inline/inlheur/score_callresult_uses.go", "repo_id": "go", "token_count": 4866 }
92
// Copyright 2023 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Package interleaved implements the interleaved devirtualization and // inlining pass. package interleaved import ( "cmd/compile/internal/base" "cmd/compile/internal/devirtualize" "cmd/compile/internal/inline" "cmd/compile/internal/inline/inlheur" "cmd/compile/internal/ir" "cmd/compile/internal/pgoir" "cmd/compile/internal/typecheck" "fmt" ) // DevirtualizeAndInlinePackage interleaves devirtualization and inlining on // all functions within pkg. func DevirtualizeAndInlinePackage(pkg *ir.Package, profile *pgoir.Profile) { if profile != nil && base.Debug.PGODevirtualize > 0 { // TODO(mdempsky): Integrate into DevirtualizeAndInlineFunc below. ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func(list []*ir.Func, recursive bool) { for _, fn := range list { devirtualize.ProfileGuided(fn, profile) } }) ir.CurFunc = nil } if base.Flag.LowerL != 0 { inlheur.SetupScoreAdjustments() } var inlProfile *pgoir.Profile // copy of profile for inlining if base.Debug.PGOInline != 0 { inlProfile = profile } // First compute inlinability of all functions in the package. inline.CanInlineFuncs(pkg.Funcs, inlProfile) // Now we make a second pass to do devirtualization and inlining of // calls. Order here should not matter. for _, fn := range pkg.Funcs { DevirtualizeAndInlineFunc(fn, inlProfile) } if base.Flag.LowerL != 0 { if base.Debug.DumpInlFuncProps != "" { inlheur.DumpFuncProps(nil, base.Debug.DumpInlFuncProps) } if inlheur.Enabled() { inline.PostProcessCallSites(inlProfile) inlheur.TearDown() } } } // DevirtualizeAndInlineFunc interleaves devirtualization and inlining // on a single function. func DevirtualizeAndInlineFunc(fn *ir.Func, profile *pgoir.Profile) { ir.WithFunc(fn, func() { if base.Flag.LowerL != 0 { if inlheur.Enabled() && !fn.Wrapper() { inlheur.ScoreCalls(fn) defer inlheur.ScoreCallsCleanup() } if base.Debug.DumpInlFuncProps != "" && !fn.Wrapper() { inlheur.DumpFuncProps(fn, base.Debug.DumpInlFuncProps) } } bigCaller := base.Flag.LowerL != 0 && inline.IsBigFunc(fn) if bigCaller && base.Flag.LowerM > 1 { fmt.Printf("%v: function %v considered 'big'; reducing max cost of inlinees\n", ir.Line(fn), fn) } match := func(n ir.Node) bool { switch n := n.(type) { case *ir.CallExpr: return true case *ir.TailCallStmt: n.Call.NoInline = true // can't inline yet } return false } edit := func(n ir.Node) ir.Node { call, ok := n.(*ir.CallExpr) if !ok { // previously inlined return nil } devirtualize.StaticCall(call) if inlCall := inline.TryInlineCall(fn, call, bigCaller, profile); inlCall != nil { return inlCall } return nil } fixpoint(fn, match, edit) }) } // fixpoint repeatedly edits a function until it stabilizes. // // First, fixpoint applies match to every node n within fn. Then it // iteratively applies edit to each node satisfying match(n). // // If edit(n) returns nil, no change is made. Otherwise, the result // replaces n in fn's body, and fixpoint iterates at least once more. // // After an iteration where all edit calls return nil, fixpoint // returns. func fixpoint(fn *ir.Func, match func(ir.Node) bool, edit func(ir.Node) ir.Node) { // Consider the expression "f(g())". We want to be able to replace // "g()" in-place with its inlined representation. But if we first // replace "f(...)" with its inlined representation, then "g()" will // instead appear somewhere within this new AST. // // To mitigate this, each matched node n is wrapped in a ParenExpr, // so we can reliably replace n in-place by assigning ParenExpr.X. // It's safe to use ParenExpr here, because typecheck already // removed them all. var parens []*ir.ParenExpr var mark func(ir.Node) ir.Node mark = func(n ir.Node) ir.Node { if _, ok := n.(*ir.ParenExpr); ok { return n // already visited n.X before wrapping } ok := match(n) ir.EditChildren(n, mark) if ok { paren := ir.NewParenExpr(n.Pos(), n) paren.SetType(n.Type()) paren.SetTypecheck(n.Typecheck()) parens = append(parens, paren) n = paren } return n } ir.EditChildren(fn, mark) // Edit until stable. for { done := true for i := 0; i < len(parens); i++ { // can't use "range parens" here paren := parens[i] if new := edit(paren.X); new != nil { // Update AST and recursively mark nodes. paren.X = new ir.EditChildren(new, mark) // mark may append to parens done = false } } if done { break } } // Finally, remove any parens we inserted. if len(parens) == 0 { return // short circuit } var unparen func(ir.Node) ir.Node unparen = func(n ir.Node) ir.Node { if paren, ok := n.(*ir.ParenExpr); ok { n = paren.X } ir.EditChildren(n, unparen) return n } ir.EditChildren(fn, unparen) }
go/src/cmd/compile/internal/inline/interleaved/interleaved.go/0
{ "file_path": "go/src/cmd/compile/internal/inline/interleaved/interleaved.go", "repo_id": "go", "token_count": 1939 }
93
// Copyright 2022 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. //go:build ignore // Note: this program must be run in this directory. // go run mknode.go package main import ( "bytes" "fmt" "go/ast" "go/format" "go/parser" "go/token" "io/fs" "log" "os" "sort" "strings" ) var fset = token.NewFileSet() var buf bytes.Buffer // concreteNodes contains all concrete types in the package that implement Node // (except for the mini* types). var concreteNodes []*ast.TypeSpec // interfaceNodes contains all interface types in the package that implement Node. var interfaceNodes []*ast.TypeSpec // mini contains the embeddable mini types (miniNode, miniExpr, and miniStmt). var mini = map[string]*ast.TypeSpec{} // implementsNode reports whether the type t is one which represents a Node // in the AST. func implementsNode(t ast.Expr) bool { id, ok := t.(*ast.Ident) if !ok { return false // only named types } for _, ts := range interfaceNodes { if ts.Name.Name == id.Name { return true } } for _, ts := range concreteNodes { if ts.Name.Name == id.Name { return true } } return false } func isMini(t ast.Expr) bool { id, ok := t.(*ast.Ident) return ok && mini[id.Name] != nil } func isNamedType(t ast.Expr, name string) bool { if id, ok := t.(*ast.Ident); ok { if id.Name == name { return true } } return false } func main() { fmt.Fprintln(&buf, "// Code generated by mknode.go. DO NOT EDIT.") fmt.Fprintln(&buf) fmt.Fprintln(&buf, "package ir") fmt.Fprintln(&buf) fmt.Fprintln(&buf, `import "fmt"`) filter := func(file fs.FileInfo) bool { return !strings.HasPrefix(file.Name(), "mknode") } pkgs, err := parser.ParseDir(fset, ".", filter, 0) if err != nil { panic(err) } pkg := pkgs["ir"] // Find all the mini types. These let us determine which // concrete types implement Node, so we need to find them first. for _, f := range pkg.Files { for _, d := range f.Decls { g, ok := d.(*ast.GenDecl) if !ok { continue } for _, s := range g.Specs { t, ok := s.(*ast.TypeSpec) if !ok { continue } if strings.HasPrefix(t.Name.Name, "mini") { mini[t.Name.Name] = t // Double-check that it is or embeds miniNode. if t.Name.Name != "miniNode" { s := t.Type.(*ast.StructType) if !isNamedType(s.Fields.List[0].Type, "miniNode") { panic(fmt.Sprintf("can't find miniNode in %s", t.Name.Name)) } } } } } } // Find all the declarations of concrete types that implement Node. for _, f := range pkg.Files { for _, d := range f.Decls { g, ok := d.(*ast.GenDecl) if !ok { continue } for _, s := range g.Specs { t, ok := s.(*ast.TypeSpec) if !ok { continue } if strings.HasPrefix(t.Name.Name, "mini") { // We don't treat the mini types as // concrete implementations of Node // (even though they are) because // we only use them by embedding them. continue } if isConcreteNode(t) { concreteNodes = append(concreteNodes, t) } if isInterfaceNode(t) { interfaceNodes = append(interfaceNodes, t) } } } } // Sort for deterministic output. sort.Slice(concreteNodes, func(i, j int) bool { return concreteNodes[i].Name.Name < concreteNodes[j].Name.Name }) // Generate code for each concrete type. for _, t := range concreteNodes { processType(t) } // Add some helpers. generateHelpers() // Format and write output. out, err := format.Source(buf.Bytes()) if err != nil { // write out mangled source so we can see the bug. out = buf.Bytes() } err = os.WriteFile("node_gen.go", out, 0666) if err != nil { log.Fatal(err) } } // isConcreteNode reports whether the type t is a concrete type // implementing Node. func isConcreteNode(t *ast.TypeSpec) bool { s, ok := t.Type.(*ast.StructType) if !ok { return false } for _, f := range s.Fields.List { if isMini(f.Type) { return true } } return false } // isInterfaceNode reports whether the type t is an interface type // implementing Node (including Node itself). func isInterfaceNode(t *ast.TypeSpec) bool { s, ok := t.Type.(*ast.InterfaceType) if !ok { return false } if t.Name.Name == "Node" { return true } if t.Name.Name == "OrigNode" || t.Name.Name == "InitNode" { // These we exempt from consideration (fields of // this type don't need to be walked or copied). return false } // Look for embedded Node type. // Note that this doesn't handle multi-level embedding, but // we have none of that at the moment. for _, f := range s.Methods.List { if len(f.Names) != 0 { continue } if isNamedType(f.Type, "Node") { return true } } return false } func processType(t *ast.TypeSpec) { name := t.Name.Name fmt.Fprintf(&buf, "\n") fmt.Fprintf(&buf, "func (n *%s) Format(s fmt.State, verb rune) { fmtNode(n, s, verb) }\n", name) switch name { case "Name", "Func": // Too specialized to automate. return } s := t.Type.(*ast.StructType) fields := s.Fields.List // Expand any embedded fields. for i := 0; i < len(fields); i++ { f := fields[i] if len(f.Names) != 0 { continue // not embedded } if isMini(f.Type) { // Insert the fields of the embedded type into the main type. // (It would be easier just to append, but inserting in place // matches the old mknode behavior.) ss := mini[f.Type.(*ast.Ident).Name].Type.(*ast.StructType) var f2 []*ast.Field f2 = append(f2, fields[:i]...) f2 = append(f2, ss.Fields.List...) f2 = append(f2, fields[i+1:]...) fields = f2 i-- continue } else if isNamedType(f.Type, "origNode") { // Ignore this field copy(fields[i:], fields[i+1:]) fields = fields[:len(fields)-1] i-- continue } else { panic("unknown embedded field " + fmt.Sprintf("%v", f.Type)) } } // Process fields. var copyBody strings.Builder var doChildrenBody strings.Builder var editChildrenBody strings.Builder var editChildrenWithHiddenBody strings.Builder for _, f := range fields { names := f.Names ft := f.Type hidden := false if f.Tag != nil { tag := f.Tag.Value[1 : len(f.Tag.Value)-1] if strings.HasPrefix(tag, "mknode:") { if tag[7:] == "\"-\"" { if !isNamedType(ft, "Node") { continue } hidden = true } else { panic(fmt.Sprintf("unexpected tag value: %s", tag)) } } } if isNamedType(ft, "Nodes") { // Nodes == []Node ft = &ast.ArrayType{Elt: &ast.Ident{Name: "Node"}} } isSlice := false if a, ok := ft.(*ast.ArrayType); ok && a.Len == nil { isSlice = true ft = a.Elt } isPtr := false if p, ok := ft.(*ast.StarExpr); ok { isPtr = true ft = p.X } if !implementsNode(ft) { continue } for _, name := range names { ptr := "" if isPtr { ptr = "*" } if isSlice { fmt.Fprintf(&editChildrenWithHiddenBody, "edit%ss(n.%s, edit)\n", ft, name) } else { fmt.Fprintf(&editChildrenWithHiddenBody, "if n.%s != nil {\nn.%s = edit(n.%s).(%s%s)\n}\n", name, name, name, ptr, ft) } if hidden { continue } if isSlice { fmt.Fprintf(&copyBody, "c.%s = copy%ss(c.%s)\n", name, ft, name) fmt.Fprintf(&doChildrenBody, "if do%ss(n.%s, do) {\nreturn true\n}\n", ft, name) fmt.Fprintf(&editChildrenBody, "edit%ss(n.%s, edit)\n", ft, name) } else { fmt.Fprintf(&doChildrenBody, "if n.%s != nil && do(n.%s) {\nreturn true\n}\n", name, name) fmt.Fprintf(&editChildrenBody, "if n.%s != nil {\nn.%s = edit(n.%s).(%s%s)\n}\n", name, name, name, ptr, ft) } } } fmt.Fprintf(&buf, "func (n *%s) copy() Node {\nc := *n\n", name) buf.WriteString(copyBody.String()) fmt.Fprintf(&buf, "return &c\n}\n") fmt.Fprintf(&buf, "func (n *%s) doChildren(do func(Node) bool) bool {\n", name) buf.WriteString(doChildrenBody.String()) fmt.Fprintf(&buf, "return false\n}\n") fmt.Fprintf(&buf, "func (n *%s) editChildren(edit func(Node) Node) {\n", name) buf.WriteString(editChildrenBody.String()) fmt.Fprintf(&buf, "}\n") fmt.Fprintf(&buf, "func (n *%s) editChildrenWithHidden(edit func(Node) Node) {\n", name) buf.WriteString(editChildrenWithHiddenBody.String()) fmt.Fprintf(&buf, "}\n") } func generateHelpers() { for _, typ := range []string{"CaseClause", "CommClause", "Name", "Node"} { ptr := "*" if typ == "Node" { ptr = "" // interfaces don't need * } fmt.Fprintf(&buf, "\n") fmt.Fprintf(&buf, "func copy%ss(list []%s%s) []%s%s {\n", typ, ptr, typ, ptr, typ) fmt.Fprintf(&buf, "if list == nil { return nil }\n") fmt.Fprintf(&buf, "c := make([]%s%s, len(list))\n", ptr, typ) fmt.Fprintf(&buf, "copy(c, list)\n") fmt.Fprintf(&buf, "return c\n") fmt.Fprintf(&buf, "}\n") fmt.Fprintf(&buf, "func do%ss(list []%s%s, do func(Node) bool) bool {\n", typ, ptr, typ) fmt.Fprintf(&buf, "for _, x := range list {\n") fmt.Fprintf(&buf, "if x != nil && do(x) {\n") fmt.Fprintf(&buf, "return true\n") fmt.Fprintf(&buf, "}\n") fmt.Fprintf(&buf, "}\n") fmt.Fprintf(&buf, "return false\n") fmt.Fprintf(&buf, "}\n") fmt.Fprintf(&buf, "func edit%ss(list []%s%s, edit func(Node) Node) {\n", typ, ptr, typ) fmt.Fprintf(&buf, "for i, x := range list {\n") fmt.Fprintf(&buf, "if x != nil {\n") fmt.Fprintf(&buf, "list[i] = edit(x).(%s%s)\n", ptr, typ) fmt.Fprintf(&buf, "}\n") fmt.Fprintf(&buf, "}\n") fmt.Fprintf(&buf, "}\n") } }
go/src/cmd/compile/internal/ir/mknode.go/0
{ "file_path": "go/src/cmd/compile/internal/ir/mknode.go", "repo_id": "go", "token_count": 4071 }
94
// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package liveness import "cmd/compile/internal/bitvec" // FNV-1 hash function constants. const ( h0 = 2166136261 hp = 16777619 ) // bvecSet is a set of bvecs, in initial insertion order. type bvecSet struct { index []int // hash -> uniq index. -1 indicates empty slot. uniq []bitvec.BitVec // unique bvecs, in insertion order } func (m *bvecSet) grow() { // Allocate new index. n := len(m.index) * 2 if n == 0 { n = 32 } newIndex := make([]int, n) for i := range newIndex { newIndex[i] = -1 } // Rehash into newIndex. for i, bv := range m.uniq { h := hashbitmap(h0, bv) % uint32(len(newIndex)) for { j := newIndex[h] if j < 0 { newIndex[h] = i break } h++ if h == uint32(len(newIndex)) { h = 0 } } } m.index = newIndex } // add adds bv to the set and returns its index in m.extractUnique, // and whether it is newly added. // If it is newly added, the caller must not modify bv after this. func (m *bvecSet) add(bv bitvec.BitVec) (int, bool) { if len(m.uniq)*4 >= len(m.index) { m.grow() } index := m.index h := hashbitmap(h0, bv) % uint32(len(index)) for { j := index[h] if j < 0 { // New bvec. index[h] = len(m.uniq) m.uniq = append(m.uniq, bv) return len(m.uniq) - 1, true } jlive := m.uniq[j] if bv.Eq(jlive) { // Existing bvec. return j, false } h++ if h == uint32(len(index)) { h = 0 } } } // extractUnique returns this slice of unique bit vectors in m, as // indexed by the result of bvecSet.add. func (m *bvecSet) extractUnique() []bitvec.BitVec { return m.uniq } func hashbitmap(h uint32, bv bitvec.BitVec) uint32 { n := int((bv.N + 31) / 32) for i := 0; i < n; i++ { w := bv.B[i] h = (h * hp) ^ (w & 0xff) h = (h * hp) ^ ((w >> 8) & 0xff) h = (h * hp) ^ ((w >> 16) & 0xff) h = (h * hp) ^ ((w >> 24) & 0xff) } return h }
go/src/cmd/compile/internal/liveness/bvset.go/0
{ "file_path": "go/src/cmd/compile/internal/liveness/bvset.go", "repo_id": "go", "token_count": 910 }
95
// Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package mips64 import ( "cmd/compile/internal/ssa" "cmd/compile/internal/ssagen" "cmd/internal/obj/mips" "internal/buildcfg" ) func Init(arch *ssagen.ArchInfo) { arch.LinkArch = &mips.Linkmips64 if buildcfg.GOARCH == "mips64le" { arch.LinkArch = &mips.Linkmips64le } arch.REGSP = mips.REGSP arch.MAXWIDTH = 1 << 50 arch.SoftFloat = buildcfg.GOMIPS64 == "softfloat" arch.ZeroRange = zerorange arch.Ginsnop = ginsnop arch.SSAMarkMoves = func(s *ssagen.State, b *ssa.Block) {} arch.SSAGenValue = ssaGenValue arch.SSAGenBlock = ssaGenBlock }
go/src/cmd/compile/internal/mips64/galign.go/0
{ "file_path": "go/src/cmd/compile/internal/mips64/galign.go", "repo_id": "go", "token_count": 284 }
96
// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package noder import ( "cmd/compile/internal/ir" "cmd/compile/internal/syntax" ) // TODO(mdempsky): Investigate replacing with switch statements or dense arrays. var branchOps = [...]ir.Op{ syntax.Break: ir.OBREAK, syntax.Continue: ir.OCONTINUE, syntax.Fallthrough: ir.OFALL, syntax.Goto: ir.OGOTO, } var callOps = [...]ir.Op{ syntax.Defer: ir.ODEFER, syntax.Go: ir.OGO, }
go/src/cmd/compile/internal/noder/stmt.go/0
{ "file_path": "go/src/cmd/compile/internal/noder/stmt.go", "repo_id": "go", "token_count": 220 }
97
// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package reflectdata_test import ( "testing" ) func BenchmarkEqArrayOfStrings5(b *testing.B) { var a [5]string var c [5]string for i := 0; i < 5; i++ { a[i] = "aaaa" c[i] = "cccc" } for j := 0; j < b.N; j++ { _ = a == c } } func BenchmarkEqArrayOfStrings64(b *testing.B) { var a [64]string var c [64]string for i := 0; i < 64; i++ { a[i] = "aaaa" c[i] = "cccc" } for j := 0; j < b.N; j++ { _ = a == c } } func BenchmarkEqArrayOfStrings1024(b *testing.B) { var a [1024]string var c [1024]string for i := 0; i < 1024; i++ { a[i] = "aaaa" c[i] = "cccc" } for j := 0; j < b.N; j++ { _ = a == c } } func BenchmarkEqArrayOfFloats5(b *testing.B) { var a [5]float32 var c [5]float32 for i := 0; i < b.N; i++ { _ = a == c } } func BenchmarkEqArrayOfFloats64(b *testing.B) { var a [64]float32 var c [64]float32 for i := 0; i < b.N; i++ { _ = a == c } } func BenchmarkEqArrayOfFloats1024(b *testing.B) { var a [1024]float32 var c [1024]float32 for i := 0; i < b.N; i++ { _ = a == c } } func BenchmarkEqArrayOfStructsEq(b *testing.B) { type T2 struct { a string b int } const size = 1024 var ( str1 = "foobar" a [size]T2 c [size]T2 ) for i := 0; i < size; i++ { a[i].a = str1 c[i].a = str1 } b.ResetTimer() for j := 0; j < b.N; j++ { _ = a == c } } func BenchmarkEqArrayOfStructsNotEq(b *testing.B) { type T2 struct { a string b int } const size = 1024 var ( str1 = "foobar" str2 = "foobarz" a [size]T2 c [size]T2 ) for i := 0; i < size; i++ { a[i].a = str1 c[i].a = str1 } c[len(c)-1].a = str2 b.ResetTimer() for j := 0; j < b.N; j++ { _ = a == c } } const size = 16 type T1 struct { a [size]byte } func BenchmarkEqStruct(b *testing.B) { x, y := T1{}, T1{} x.a = [size]byte{1, 2, 3, 4, 5, 6, 7, 8} y.a = [size]byte{2, 3, 4, 5, 6, 7, 8, 9} for i := 0; i < b.N; i++ { f := x == y if f { println("hello") } } }
go/src/cmd/compile/internal/reflectdata/alg_test.go/0
{ "file_path": "go/src/cmd/compile/internal/reflectdata/alg_test.go", "repo_id": "go", "token_count": 1069 }
98
// Copyright 2015 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. // Lowering arithmetic (Add(64|32|16|8) ...) => (ADD(Q|L|L|L) ...) (AddPtr ...) => (ADDQ ...) (Add(32|64)F ...) => (ADDS(S|D) ...) (Sub(64|32|16|8) ...) => (SUB(Q|L|L|L) ...) (SubPtr ...) => (SUBQ ...) (Sub(32|64)F ...) => (SUBS(S|D) ...) (Mul(64|32|16|8) ...) => (MUL(Q|L|L|L) ...) (Mul(32|64)F ...) => (MULS(S|D) ...) (Select0 (Mul64uover x y)) => (Select0 <typ.UInt64> (MULQU x y)) (Select0 (Mul32uover x y)) => (Select0 <typ.UInt32> (MULLU x y)) (Select1 (Mul(64|32)uover x y)) => (SETO (Select1 <types.TypeFlags> (MUL(Q|L)U x y))) (Hmul(64|32) ...) => (HMUL(Q|L) ...) (Hmul(64|32)u ...) => (HMUL(Q|L)U ...) (Div(64|32|16) [a] x y) => (Select0 (DIV(Q|L|W) [a] x y)) (Div8 x y) => (Select0 (DIVW (SignExt8to16 x) (SignExt8to16 y))) (Div(64|32|16)u x y) => (Select0 (DIV(Q|L|W)U x y)) (Div8u x y) => (Select0 (DIVWU (ZeroExt8to16 x) (ZeroExt8to16 y))) (Div(32|64)F ...) => (DIVS(S|D) ...) (Select0 (Add64carry x y c)) => (Select0 <typ.UInt64> (ADCQ x y (Select1 <types.TypeFlags> (NEGLflags c)))) (Select1 (Add64carry x y c)) => (NEGQ <typ.UInt64> (SBBQcarrymask <typ.UInt64> (Select1 <types.TypeFlags> (ADCQ x y (Select1 <types.TypeFlags> (NEGLflags c)))))) (Select0 (Sub64borrow x y c)) => (Select0 <typ.UInt64> (SBBQ x y (Select1 <types.TypeFlags> (NEGLflags c)))) (Select1 (Sub64borrow x y c)) => (NEGQ <typ.UInt64> (SBBQcarrymask <typ.UInt64> (Select1 <types.TypeFlags> (SBBQ x y (Select1 <types.TypeFlags> (NEGLflags c)))))) // Optimize ADCQ and friends (ADCQ x (MOVQconst [c]) carry) && is32Bit(c) => (ADCQconst x [int32(c)] carry) (ADCQ x y (FlagEQ)) => (ADDQcarry x y) (ADCQconst x [c] (FlagEQ)) => (ADDQconstcarry x [c]) (ADDQcarry x (MOVQconst [c])) && is32Bit(c) => (ADDQconstcarry x [int32(c)]) (SBBQ x (MOVQconst [c]) borrow) && is32Bit(c) => (SBBQconst x [int32(c)] borrow) (SBBQ x y (FlagEQ)) => (SUBQborrow x y) (SBBQconst x [c] (FlagEQ)) => (SUBQconstborrow x [c]) (SUBQborrow x (MOVQconst [c])) && is32Bit(c) => (SUBQconstborrow x [int32(c)]) (Select1 (NEGLflags (MOVQconst [0]))) => (FlagEQ) (Select1 (NEGLflags (NEGQ (SBBQcarrymask x)))) => x (Mul64uhilo ...) => (MULQU2 ...) (Div128u ...) => (DIVQU2 ...) (Avg64u ...) => (AVGQU ...) (Mod(64|32|16) [a] x y) => (Select1 (DIV(Q|L|W) [a] x y)) (Mod8 x y) => (Select1 (DIVW (SignExt8to16 x) (SignExt8to16 y))) (Mod(64|32|16)u x y) => (Select1 (DIV(Q|L|W)U x y)) (Mod8u x y) => (Select1 (DIVWU (ZeroExt8to16 x) (ZeroExt8to16 y))) (And(64|32|16|8) ...) => (AND(Q|L|L|L) ...) (Or(64|32|16|8) ...) => (OR(Q|L|L|L) ...) (Xor(64|32|16|8) ...) => (XOR(Q|L|L|L) ...) (Com(64|32|16|8) ...) => (NOT(Q|L|L|L) ...) (Neg(64|32|16|8) ...) => (NEG(Q|L|L|L) ...) (Neg32F x) => (PXOR x (MOVSSconst <typ.Float32> [float32(math.Copysign(0, -1))])) (Neg64F x) => (PXOR x (MOVSDconst <typ.Float64> [math.Copysign(0, -1)])) // Lowering boolean ops (AndB ...) => (ANDL ...) (OrB ...) => (ORL ...) (Not x) => (XORLconst [1] x) // Lowering pointer arithmetic (OffPtr [off] ptr) && is32Bit(off) => (ADDQconst [int32(off)] ptr) (OffPtr [off] ptr) => (ADDQ (MOVQconst [off]) ptr) // Lowering other arithmetic (Ctz64 x) && buildcfg.GOAMD64 >= 3 => (TZCNTQ x) (Ctz32 x) && buildcfg.GOAMD64 >= 3 => (TZCNTL x) (Ctz64 <t> x) && buildcfg.GOAMD64 < 3 => (CMOVQEQ (Select0 <t> (BSFQ x)) (MOVQconst <t> [64]) (Select1 <types.TypeFlags> (BSFQ x))) (Ctz32 x) && buildcfg.GOAMD64 < 3 => (Select0 (BSFQ (BTSQconst <typ.UInt64> [32] x))) (Ctz16 x) => (BSFL (ORLconst <typ.UInt32> [1<<16] x)) (Ctz8 x) => (BSFL (ORLconst <typ.UInt32> [1<<8 ] x)) (Ctz64NonZero x) && buildcfg.GOAMD64 >= 3 => (TZCNTQ x) (Ctz32NonZero x) && buildcfg.GOAMD64 >= 3 => (TZCNTL x) (Ctz16NonZero x) && buildcfg.GOAMD64 >= 3 => (TZCNTL x) (Ctz8NonZero x) && buildcfg.GOAMD64 >= 3 => (TZCNTL x) (Ctz64NonZero x) && buildcfg.GOAMD64 < 3 => (Select0 (BSFQ x)) (Ctz32NonZero x) && buildcfg.GOAMD64 < 3 => (BSFL x) (Ctz16NonZero x) && buildcfg.GOAMD64 < 3 => (BSFL x) (Ctz8NonZero x) && buildcfg.GOAMD64 < 3 => (BSFL x) // BitLen64 of a 64 bit value x requires checking whether x == 0, since BSRQ is undefined when x == 0. // However, for zero-extended values, we can cheat a bit, and calculate // BSR(x<<1 + 1), which is guaranteed to be non-zero, and which conveniently // places the index of the highest set bit where we want it. // For GOAMD64>=3, BitLen can be calculated by OperandSize - LZCNT(x). (BitLen64 <t> x) && buildcfg.GOAMD64 < 3 => (ADDQconst [1] (CMOVQEQ <t> (Select0 <t> (BSRQ x)) (MOVQconst <t> [-1]) (Select1 <types.TypeFlags> (BSRQ x)))) (BitLen32 x) && buildcfg.GOAMD64 < 3 => (Select0 (BSRQ (LEAQ1 <typ.UInt64> [1] (MOVLQZX <typ.UInt64> x) (MOVLQZX <typ.UInt64> x)))) (BitLen16 x) && buildcfg.GOAMD64 < 3 => (BSRL (LEAL1 <typ.UInt32> [1] (MOVWQZX <typ.UInt32> x) (MOVWQZX <typ.UInt32> x))) (BitLen8 x) && buildcfg.GOAMD64 < 3 => (BSRL (LEAL1 <typ.UInt32> [1] (MOVBQZX <typ.UInt32> x) (MOVBQZX <typ.UInt32> x))) (BitLen64 <t> x) && buildcfg.GOAMD64 >= 3 => (NEGQ (ADDQconst <t> [-64] (LZCNTQ x))) // Use 64-bit version to allow const-fold remove unnecessary arithmetic. (BitLen32 <t> x) && buildcfg.GOAMD64 >= 3 => (NEGQ (ADDQconst <t> [-32] (LZCNTL x))) (BitLen16 <t> x) && buildcfg.GOAMD64 >= 3 => (NEGQ (ADDQconst <t> [-32] (LZCNTL (MOVWQZX <x.Type> x)))) (BitLen8 <t> x) && buildcfg.GOAMD64 >= 3 => (NEGQ (ADDQconst <t> [-32] (LZCNTL (MOVBQZX <x.Type> x)))) (Bswap(64|32) ...) => (BSWAP(Q|L) ...) (Bswap16 x) => (ROLWconst [8] x) (PopCount(64|32) ...) => (POPCNT(Q|L) ...) (PopCount16 x) => (POPCNTL (MOVWQZX <typ.UInt32> x)) (PopCount8 x) => (POPCNTL (MOVBQZX <typ.UInt32> x)) (Sqrt ...) => (SQRTSD ...) (Sqrt32 ...) => (SQRTSS ...) (RoundToEven x) => (ROUNDSD [0] x) (Floor x) => (ROUNDSD [1] x) (Ceil x) => (ROUNDSD [2] x) (Trunc x) => (ROUNDSD [3] x) (FMA x y z) => (VFMADD231SD z x y) // Lowering extension // Note: we always extend to 64 bits even though some ops don't need that many result bits. (SignExt8to16 ...) => (MOVBQSX ...) (SignExt8to32 ...) => (MOVBQSX ...) (SignExt8to64 ...) => (MOVBQSX ...) (SignExt16to32 ...) => (MOVWQSX ...) (SignExt16to64 ...) => (MOVWQSX ...) (SignExt32to64 ...) => (MOVLQSX ...) (ZeroExt8to16 ...) => (MOVBQZX ...) (ZeroExt8to32 ...) => (MOVBQZX ...) (ZeroExt8to64 ...) => (MOVBQZX ...) (ZeroExt16to32 ...) => (MOVWQZX ...) (ZeroExt16to64 ...) => (MOVWQZX ...) (ZeroExt32to64 ...) => (MOVLQZX ...) (Slicemask <t> x) => (SARQconst (NEGQ <t> x) [63]) (SpectreIndex <t> x y) => (CMOVQCC x (MOVQconst [0]) (CMPQ x y)) (SpectreSliceIndex <t> x y) => (CMOVQHI x (MOVQconst [0]) (CMPQ x y)) // Lowering truncation // Because we ignore high parts of registers, truncates are just copies. (Trunc16to8 ...) => (Copy ...) (Trunc32to8 ...) => (Copy ...) (Trunc32to16 ...) => (Copy ...) (Trunc64to8 ...) => (Copy ...) (Trunc64to16 ...) => (Copy ...) (Trunc64to32 ...) => (Copy ...) // Lowering float <-> int (Cvt32to32F ...) => (CVTSL2SS ...) (Cvt32to64F ...) => (CVTSL2SD ...) (Cvt64to32F ...) => (CVTSQ2SS ...) (Cvt64to64F ...) => (CVTSQ2SD ...) (Cvt32Fto32 ...) => (CVTTSS2SL ...) (Cvt32Fto64 ...) => (CVTTSS2SQ ...) (Cvt64Fto32 ...) => (CVTTSD2SL ...) (Cvt64Fto64 ...) => (CVTTSD2SQ ...) (Cvt32Fto64F ...) => (CVTSS2SD ...) (Cvt64Fto32F ...) => (CVTSD2SS ...) (Round(32|64)F ...) => (Copy ...) // Floating-point min is tricky, as the hardware op isn't right for various special // cases (-0 and NaN). We use two hardware ops organized just right to make the // result come out how we want it. See https://github.com/golang/go/issues/59488#issuecomment-1553493207 // (although that comment isn't exactly right, as the value overwritten is not simulated correctly). // t1 = MINSD x, y => incorrect if x==NaN or x==-0,y==+0 // t2 = MINSD t1, x => fixes x==NaN case // res = POR t1, t2 => fixes x==-0,y==+0 case // Note that this trick depends on the special property that (NaN OR x) produces a NaN (although // it might not produce the same NaN as the input). (Min(64|32)F <t> x y) => (POR (MINS(D|S) <t> (MINS(D|S) <t> x y) x) (MINS(D|S) <t> x y)) // Floating-point max is even trickier. Punt to using min instead. // max(x,y) == -min(-x,-y) (Max(64|32)F <t> x y) => (Neg(64|32)F <t> (Min(64|32)F <t> (Neg(64|32)F <t> x) (Neg(64|32)F <t> y))) (CvtBoolToUint8 ...) => (Copy ...) // Lowering shifts // Unsigned shifts need to return 0 if shift amount is >= width of shifted value. // result = (arg << shift) & (shift >= argbits ? 0 : 0xffffffffffffffff) (Lsh64x(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (ANDQ (SHLQ <t> x y) (SBBQcarrymask <t> (CMP(Q|L|W|B)const y [64]))) (Lsh32x(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (ANDL (SHLL <t> x y) (SBBLcarrymask <t> (CMP(Q|L|W|B)const y [32]))) (Lsh16x(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (ANDL (SHLL <t> x y) (SBBLcarrymask <t> (CMP(Q|L|W|B)const y [32]))) (Lsh8x(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (ANDL (SHLL <t> x y) (SBBLcarrymask <t> (CMP(Q|L|W|B)const y [32]))) (Lsh64x(64|32|16|8) x y) && shiftIsBounded(v) => (SHLQ x y) (Lsh32x(64|32|16|8) x y) && shiftIsBounded(v) => (SHLL x y) (Lsh16x(64|32|16|8) x y) && shiftIsBounded(v) => (SHLL x y) (Lsh8x(64|32|16|8) x y) && shiftIsBounded(v) => (SHLL x y) (Rsh64Ux(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (ANDQ (SHRQ <t> x y) (SBBQcarrymask <t> (CMP(Q|L|W|B)const y [64]))) (Rsh32Ux(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (ANDL (SHRL <t> x y) (SBBLcarrymask <t> (CMP(Q|L|W|B)const y [32]))) (Rsh16Ux(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (ANDL (SHRW <t> x y) (SBBLcarrymask <t> (CMP(Q|L|W|B)const y [16]))) (Rsh8Ux(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (ANDL (SHRB <t> x y) (SBBLcarrymask <t> (CMP(Q|L|W|B)const y [8]))) (Rsh64Ux(64|32|16|8) x y) && shiftIsBounded(v) => (SHRQ x y) (Rsh32Ux(64|32|16|8) x y) && shiftIsBounded(v) => (SHRL x y) (Rsh16Ux(64|32|16|8) x y) && shiftIsBounded(v) => (SHRW x y) (Rsh8Ux(64|32|16|8) x y) && shiftIsBounded(v) => (SHRB x y) // Signed right shift needs to return 0/-1 if shift amount is >= width of shifted value. // We implement this by setting the shift value to -1 (all ones) if the shift value is >= width. (Rsh64x(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (SARQ <t> x (OR(Q|L|L|L) <y.Type> y (NOT(Q|L|L|L) <y.Type> (SBB(Q|L|L|L)carrymask <y.Type> (CMP(Q|L|W|B)const y [64]))))) (Rsh32x(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (SARL <t> x (OR(Q|L|L|L) <y.Type> y (NOT(Q|L|L|L) <y.Type> (SBB(Q|L|L|L)carrymask <y.Type> (CMP(Q|L|W|B)const y [32]))))) (Rsh16x(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (SARW <t> x (OR(Q|L|L|L) <y.Type> y (NOT(Q|L|L|L) <y.Type> (SBB(Q|L|L|L)carrymask <y.Type> (CMP(Q|L|W|B)const y [16]))))) (Rsh8x(64|32|16|8) <t> x y) && !shiftIsBounded(v) => (SARB <t> x (OR(Q|L|L|L) <y.Type> y (NOT(Q|L|L|L) <y.Type> (SBB(Q|L|L|L)carrymask <y.Type> (CMP(Q|L|W|B)const y [8]))))) (Rsh64x(64|32|16|8) x y) && shiftIsBounded(v) => (SARQ x y) (Rsh32x(64|32|16|8) x y) && shiftIsBounded(v) => (SARL x y) (Rsh16x(64|32|16|8) x y) && shiftIsBounded(v) => (SARW x y) (Rsh8x(64|32|16|8) x y) && shiftIsBounded(v) => (SARB x y) // Lowering integer comparisons (Less(64|32|16|8) x y) => (SETL (CMP(Q|L|W|B) x y)) (Less(64|32|16|8)U x y) => (SETB (CMP(Q|L|W|B) x y)) (Leq(64|32|16|8) x y) => (SETLE (CMP(Q|L|W|B) x y)) (Leq(64|32|16|8)U x y) => (SETBE (CMP(Q|L|W|B) x y)) (Eq(Ptr|64|32|16|8|B) x y) => (SETEQ (CMP(Q|Q|L|W|B|B) x y)) (Neq(Ptr|64|32|16|8|B) x y) => (SETNE (CMP(Q|Q|L|W|B|B) x y)) // Lowering floating point comparisons // Note Go assembler gets UCOMISx operand order wrong, but it is right here // and the operands are reversed when generating assembly language. (Eq(32|64)F x y) => (SETEQF (UCOMIS(S|D) x y)) (Neq(32|64)F x y) => (SETNEF (UCOMIS(S|D) x y)) // Use SETGF/SETGEF with reversed operands to dodge NaN case. (Less(32|64)F x y) => (SETGF (UCOMIS(S|D) y x)) (Leq(32|64)F x y) => (SETGEF (UCOMIS(S|D) y x)) // Lowering loads (Load <t> ptr mem) && (is64BitInt(t) || isPtr(t)) => (MOVQload ptr mem) (Load <t> ptr mem) && is32BitInt(t) => (MOVLload ptr mem) (Load <t> ptr mem) && is16BitInt(t) => (MOVWload ptr mem) (Load <t> ptr mem) && (t.IsBoolean() || is8BitInt(t)) => (MOVBload ptr mem) (Load <t> ptr mem) && is32BitFloat(t) => (MOVSSload ptr mem) (Load <t> ptr mem) && is64BitFloat(t) => (MOVSDload ptr mem) // Lowering stores (Store {t} ptr val mem) && t.Size() == 8 && t.IsFloat() => (MOVSDstore ptr val mem) (Store {t} ptr val mem) && t.Size() == 4 && t.IsFloat() => (MOVSSstore ptr val mem) (Store {t} ptr val mem) && t.Size() == 8 && !t.IsFloat() => (MOVQstore ptr val mem) (Store {t} ptr val mem) && t.Size() == 4 && !t.IsFloat() => (MOVLstore ptr val mem) (Store {t} ptr val mem) && t.Size() == 2 => (MOVWstore ptr val mem) (Store {t} ptr val mem) && t.Size() == 1 => (MOVBstore ptr val mem) // Lowering moves (Move [0] _ _ mem) => mem (Move [1] dst src mem) => (MOVBstore dst (MOVBload src mem) mem) (Move [2] dst src mem) => (MOVWstore dst (MOVWload src mem) mem) (Move [4] dst src mem) => (MOVLstore dst (MOVLload src mem) mem) (Move [8] dst src mem) => (MOVQstore dst (MOVQload src mem) mem) (Move [16] dst src mem) && config.useSSE => (MOVOstore dst (MOVOload src mem) mem) (Move [16] dst src mem) && !config.useSSE => (MOVQstore [8] dst (MOVQload [8] src mem) (MOVQstore dst (MOVQload src mem) mem)) (Move [32] dst src mem) => (Move [16] (OffPtr <dst.Type> dst [16]) (OffPtr <src.Type> src [16]) (Move [16] dst src mem)) (Move [48] dst src mem) && config.useSSE => (Move [32] (OffPtr <dst.Type> dst [16]) (OffPtr <src.Type> src [16]) (Move [16] dst src mem)) (Move [64] dst src mem) && config.useSSE => (Move [32] (OffPtr <dst.Type> dst [32]) (OffPtr <src.Type> src [32]) (Move [32] dst src mem)) (Move [3] dst src mem) => (MOVBstore [2] dst (MOVBload [2] src mem) (MOVWstore dst (MOVWload src mem) mem)) (Move [5] dst src mem) => (MOVBstore [4] dst (MOVBload [4] src mem) (MOVLstore dst (MOVLload src mem) mem)) (Move [6] dst src mem) => (MOVWstore [4] dst (MOVWload [4] src mem) (MOVLstore dst (MOVLload src mem) mem)) (Move [7] dst src mem) => (MOVLstore [3] dst (MOVLload [3] src mem) (MOVLstore dst (MOVLload src mem) mem)) (Move [9] dst src mem) => (MOVBstore [8] dst (MOVBload [8] src mem) (MOVQstore dst (MOVQload src mem) mem)) (Move [10] dst src mem) => (MOVWstore [8] dst (MOVWload [8] src mem) (MOVQstore dst (MOVQload src mem) mem)) (Move [11] dst src mem) => (MOVLstore [7] dst (MOVLload [7] src mem) (MOVQstore dst (MOVQload src mem) mem)) (Move [12] dst src mem) => (MOVLstore [8] dst (MOVLload [8] src mem) (MOVQstore dst (MOVQload src mem) mem)) (Move [s] dst src mem) && s >= 13 && s <= 15 => (MOVQstore [int32(s-8)] dst (MOVQload [int32(s-8)] src mem) (MOVQstore dst (MOVQload src mem) mem)) // Adjust moves to be a multiple of 16 bytes. (Move [s] dst src mem) && s > 16 && s%16 != 0 && s%16 <= 8 => (Move [s-s%16] (OffPtr <dst.Type> dst [s%16]) (OffPtr <src.Type> src [s%16]) (MOVQstore dst (MOVQload src mem) mem)) (Move [s] dst src mem) && s > 16 && s%16 != 0 && s%16 > 8 && config.useSSE => (Move [s-s%16] (OffPtr <dst.Type> dst [s%16]) (OffPtr <src.Type> src [s%16]) (MOVOstore dst (MOVOload src mem) mem)) (Move [s] dst src mem) && s > 16 && s%16 != 0 && s%16 > 8 && !config.useSSE => (Move [s-s%16] (OffPtr <dst.Type> dst [s%16]) (OffPtr <src.Type> src [s%16]) (MOVQstore [8] dst (MOVQload [8] src mem) (MOVQstore dst (MOVQload src mem) mem))) // Medium copying uses a duff device. (Move [s] dst src mem) && s > 64 && s <= 16*64 && s%16 == 0 && !config.noDuffDevice && logLargeCopy(v, s) => (DUFFCOPY [s] dst src mem) // Large copying uses REP MOVSQ. (Move [s] dst src mem) && (s > 16*64 || config.noDuffDevice) && s%8 == 0 && logLargeCopy(v, s) => (REPMOVSQ dst src (MOVQconst [s/8]) mem) // Lowering Zero instructions (Zero [0] _ mem) => mem (Zero [1] destptr mem) => (MOVBstoreconst [makeValAndOff(0,0)] destptr mem) (Zero [2] destptr mem) => (MOVWstoreconst [makeValAndOff(0,0)] destptr mem) (Zero [4] destptr mem) => (MOVLstoreconst [makeValAndOff(0,0)] destptr mem) (Zero [8] destptr mem) => (MOVQstoreconst [makeValAndOff(0,0)] destptr mem) (Zero [3] destptr mem) => (MOVBstoreconst [makeValAndOff(0,2)] destptr (MOVWstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [5] destptr mem) => (MOVBstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [6] destptr mem) => (MOVWstoreconst [makeValAndOff(0,4)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [7] destptr mem) => (MOVLstoreconst [makeValAndOff(0,3)] destptr (MOVLstoreconst [makeValAndOff(0,0)] destptr mem)) // Strip off any fractional word zeroing. (Zero [s] destptr mem) && s%8 != 0 && s > 8 && !config.useSSE => (Zero [s-s%8] (OffPtr <destptr.Type> destptr [s%8]) (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) // Zero small numbers of words directly. (Zero [16] destptr mem) && !config.useSSE => (MOVQstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [24] destptr mem) && !config.useSSE => (MOVQstoreconst [makeValAndOff(0,16)] destptr (MOVQstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem))) (Zero [32] destptr mem) && !config.useSSE => (MOVQstoreconst [makeValAndOff(0,24)] destptr (MOVQstoreconst [makeValAndOff(0,16)] destptr (MOVQstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)))) (Zero [9] destptr mem) && config.useSSE => (MOVBstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [10] destptr mem) && config.useSSE => (MOVWstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [11] destptr mem) && config.useSSE => (MOVLstoreconst [makeValAndOff(0,7)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [12] destptr mem) && config.useSSE => (MOVLstoreconst [makeValAndOff(0,8)] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [s] destptr mem) && s > 12 && s < 16 && config.useSSE => (MOVQstoreconst [makeValAndOff(0,int32(s-8))] destptr (MOVQstoreconst [makeValAndOff(0,0)] destptr mem)) // Adjust zeros to be a multiple of 16 bytes. (Zero [s] destptr mem) && s%16 != 0 && s > 16 && s%16 > 8 && config.useSSE => (Zero [s-s%16] (OffPtr <destptr.Type> destptr [s%16]) (MOVOstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [s] destptr mem) && s%16 != 0 && s > 16 && s%16 <= 8 && config.useSSE => (Zero [s-s%16] (OffPtr <destptr.Type> destptr [s%16]) (MOVOstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [16] destptr mem) && config.useSSE => (MOVOstoreconst [makeValAndOff(0,0)] destptr mem) (Zero [32] destptr mem) && config.useSSE => (MOVOstoreconst [makeValAndOff(0,16)] destptr (MOVOstoreconst [makeValAndOff(0,0)] destptr mem)) (Zero [48] destptr mem) && config.useSSE => (MOVOstoreconst [makeValAndOff(0,32)] destptr (MOVOstoreconst [makeValAndOff(0,16)] destptr (MOVOstoreconst [makeValAndOff(0,0)] destptr mem))) (Zero [64] destptr mem) && config.useSSE => (MOVOstoreconst [makeValAndOff(0,48)] destptr (MOVOstoreconst [makeValAndOff(0,32)] destptr (MOVOstoreconst [makeValAndOff(0,16)] destptr (MOVOstoreconst [makeValAndOff(0,0)] destptr mem)))) // Medium zeroing uses a duff device. (Zero [s] destptr mem) && s > 64 && s <= 1024 && s%16 == 0 && !config.noDuffDevice => (DUFFZERO [s] destptr mem) // Large zeroing uses REP STOSQ. (Zero [s] destptr mem) && (s > 1024 || (config.noDuffDevice && s > 64 || !config.useSSE && s > 32)) && s%8 == 0 => (REPSTOSQ destptr (MOVQconst [s/8]) (MOVQconst [0]) mem) // Lowering constants (Const8 [c]) => (MOVLconst [int32(c)]) (Const16 [c]) => (MOVLconst [int32(c)]) (Const32 ...) => (MOVLconst ...) (Const64 ...) => (MOVQconst ...) (Const32F ...) => (MOVSSconst ...) (Const64F ...) => (MOVSDconst ...) (ConstNil ) => (MOVQconst [0]) (ConstBool [c]) => (MOVLconst [b2i32(c)]) // Lowering calls (StaticCall ...) => (CALLstatic ...) (ClosureCall ...) => (CALLclosure ...) (InterCall ...) => (CALLinter ...) (TailCall ...) => (CALLtail ...) // Lowering conditional moves // If the condition is a SETxx, we can just run a CMOV from the comparison that was // setting the flags. // Legend: HI=unsigned ABOVE, CS=unsigned BELOW, CC=unsigned ABOVE EQUAL, LS=unsigned BELOW EQUAL (CondSelect <t> x y (SET(EQ|NE|L|G|LE|GE|A|B|AE|BE|EQF|NEF|GF|GEF) cond)) && (is64BitInt(t) || isPtr(t)) => (CMOVQ(EQ|NE|LT|GT|LE|GE|HI|CS|CC|LS|EQF|NEF|GTF|GEF) y x cond) (CondSelect <t> x y (SET(EQ|NE|L|G|LE|GE|A|B|AE|BE|EQF|NEF|GF|GEF) cond)) && is32BitInt(t) => (CMOVL(EQ|NE|LT|GT|LE|GE|HI|CS|CC|LS|EQF|NEF|GTF|GEF) y x cond) (CondSelect <t> x y (SET(EQ|NE|L|G|LE|GE|A|B|AE|BE|EQF|NEF|GF|GEF) cond)) && is16BitInt(t) => (CMOVW(EQ|NE|LT|GT|LE|GE|HI|CS|CC|LS|EQF|NEF|GTF|GEF) y x cond) // If the condition does not set the flags, we need to generate a comparison. (CondSelect <t> x y check) && !check.Type.IsFlags() && check.Type.Size() == 1 => (CondSelect <t> x y (MOVBQZX <typ.UInt64> check)) (CondSelect <t> x y check) && !check.Type.IsFlags() && check.Type.Size() == 2 => (CondSelect <t> x y (MOVWQZX <typ.UInt64> check)) (CondSelect <t> x y check) && !check.Type.IsFlags() && check.Type.Size() == 4 => (CondSelect <t> x y (MOVLQZX <typ.UInt64> check)) (CondSelect <t> x y check) && !check.Type.IsFlags() && check.Type.Size() == 8 && (is64BitInt(t) || isPtr(t)) => (CMOVQNE y x (CMPQconst [0] check)) (CondSelect <t> x y check) && !check.Type.IsFlags() && check.Type.Size() == 8 && is32BitInt(t) => (CMOVLNE y x (CMPQconst [0] check)) (CondSelect <t> x y check) && !check.Type.IsFlags() && check.Type.Size() == 8 && is16BitInt(t) => (CMOVWNE y x (CMPQconst [0] check)) // Absorb InvertFlags (CMOVQ(EQ|NE|LT|GT|LE|GE|HI|CS|CC|LS) x y (InvertFlags cond)) => (CMOVQ(EQ|NE|GT|LT|GE|LE|CS|HI|LS|CC) x y cond) (CMOVL(EQ|NE|LT|GT|LE|GE|HI|CS|CC|LS) x y (InvertFlags cond)) => (CMOVL(EQ|NE|GT|LT|GE|LE|CS|HI|LS|CC) x y cond) (CMOVW(EQ|NE|LT|GT|LE|GE|HI|CS|CC|LS) x y (InvertFlags cond)) => (CMOVW(EQ|NE|GT|LT|GE|LE|CS|HI|LS|CC) x y cond) // Absorb constants generated during lower (CMOV(QEQ|QLE|QGE|QCC|QLS|LEQ|LLE|LGE|LCC|LLS|WEQ|WLE|WGE|WCC|WLS) _ x (FlagEQ)) => x (CMOV(QNE|QLT|QGT|QCS|QHI|LNE|LLT|LGT|LCS|LHI|WNE|WLT|WGT|WCS|WHI) y _ (FlagEQ)) => y (CMOV(QNE|QGT|QGE|QHI|QCC|LNE|LGT|LGE|LHI|LCC|WNE|WGT|WGE|WHI|WCC) _ x (FlagGT_UGT)) => x (CMOV(QEQ|QLE|QLT|QLS|QCS|LEQ|LLE|LLT|LLS|LCS|WEQ|WLE|WLT|WLS|WCS) y _ (FlagGT_UGT)) => y (CMOV(QNE|QGT|QGE|QLS|QCS|LNE|LGT|LGE|LLS|LCS|WNE|WGT|WGE|WLS|WCS) _ x (FlagGT_ULT)) => x (CMOV(QEQ|QLE|QLT|QHI|QCC|LEQ|LLE|LLT|LHI|LCC|WEQ|WLE|WLT|WHI|WCC) y _ (FlagGT_ULT)) => y (CMOV(QNE|QLT|QLE|QCS|QLS|LNE|LLT|LLE|LCS|LLS|WNE|WLT|WLE|WCS|WLS) _ x (FlagLT_ULT)) => x (CMOV(QEQ|QGT|QGE|QHI|QCC|LEQ|LGT|LGE|LHI|LCC|WEQ|WGT|WGE|WHI|WCC) y _ (FlagLT_ULT)) => y (CMOV(QNE|QLT|QLE|QHI|QCC|LNE|LLT|LLE|LHI|LCC|WNE|WLT|WLE|WHI|WCC) _ x (FlagLT_UGT)) => x (CMOV(QEQ|QGT|QGE|QCS|QLS|LEQ|LGT|LGE|LCS|LLS|WEQ|WGT|WGE|WCS|WLS) y _ (FlagLT_UGT)) => y // Miscellaneous (IsNonNil p) => (SETNE (TESTQ p p)) (IsInBounds idx len) => (SETB (CMPQ idx len)) (IsSliceInBounds idx len) => (SETBE (CMPQ idx len)) (NilCheck ...) => (LoweredNilCheck ...) (GetG mem) && v.Block.Func.OwnAux.Fn.ABI() != obj.ABIInternal => (LoweredGetG mem) // only lower in old ABI. in new ABI we have a G register. (GetClosurePtr ...) => (LoweredGetClosurePtr ...) (GetCallerPC ...) => (LoweredGetCallerPC ...) (GetCallerSP ...) => (LoweredGetCallerSP ...) (HasCPUFeature {s}) => (SETNE (CMPLconst [0] (LoweredHasCPUFeature {s}))) (Addr {sym} base) => (LEAQ {sym} base) (LocalAddr <t> {sym} base mem) && t.Elem().HasPointers() => (LEAQ {sym} (SPanchored base mem)) (LocalAddr <t> {sym} base _) && !t.Elem().HasPointers() => (LEAQ {sym} base) (MOVBstore [off] {sym} ptr y:(SETL x) mem) && y.Uses == 1 => (SETLstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETLE x) mem) && y.Uses == 1 => (SETLEstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETG x) mem) && y.Uses == 1 => (SETGstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETGE x) mem) && y.Uses == 1 => (SETGEstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETEQ x) mem) && y.Uses == 1 => (SETEQstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETNE x) mem) && y.Uses == 1 => (SETNEstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETB x) mem) && y.Uses == 1 => (SETBstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETBE x) mem) && y.Uses == 1 => (SETBEstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETA x) mem) && y.Uses == 1 => (SETAstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr y:(SETAE x) mem) && y.Uses == 1 => (SETAEstore [off] {sym} ptr x mem) // block rewrites (If (SETL cmp) yes no) => (LT cmp yes no) (If (SETLE cmp) yes no) => (LE cmp yes no) (If (SETG cmp) yes no) => (GT cmp yes no) (If (SETGE cmp) yes no) => (GE cmp yes no) (If (SETEQ cmp) yes no) => (EQ cmp yes no) (If (SETNE cmp) yes no) => (NE cmp yes no) (If (SETB cmp) yes no) => (ULT cmp yes no) (If (SETBE cmp) yes no) => (ULE cmp yes no) (If (SETA cmp) yes no) => (UGT cmp yes no) (If (SETAE cmp) yes no) => (UGE cmp yes no) (If (SETO cmp) yes no) => (OS cmp yes no) // Special case for floating point - LF/LEF not generated (If (SETGF cmp) yes no) => (UGT cmp yes no) (If (SETGEF cmp) yes no) => (UGE cmp yes no) (If (SETEQF cmp) yes no) => (EQF cmp yes no) (If (SETNEF cmp) yes no) => (NEF cmp yes no) (If cond yes no) => (NE (TESTB cond cond) yes no) (JumpTable idx) => (JUMPTABLE {makeJumpTableSym(b)} idx (LEAQ <typ.Uintptr> {makeJumpTableSym(b)} (SB))) // Atomic loads. Other than preserving their ordering with respect to other loads, nothing special here. (AtomicLoad8 ptr mem) => (MOVBatomicload ptr mem) (AtomicLoad32 ptr mem) => (MOVLatomicload ptr mem) (AtomicLoad64 ptr mem) => (MOVQatomicload ptr mem) (AtomicLoadPtr ptr mem) => (MOVQatomicload ptr mem) // Atomic stores. We use XCHG to prevent the hardware reordering a subsequent load. // TODO: most runtime uses of atomic stores don't need that property. Use normal stores for those? (AtomicStore8 ptr val mem) => (Select1 (XCHGB <types.NewTuple(typ.UInt8,types.TypeMem)> val ptr mem)) (AtomicStore32 ptr val mem) => (Select1 (XCHGL <types.NewTuple(typ.UInt32,types.TypeMem)> val ptr mem)) (AtomicStore64 ptr val mem) => (Select1 (XCHGQ <types.NewTuple(typ.UInt64,types.TypeMem)> val ptr mem)) (AtomicStorePtrNoWB ptr val mem) => (Select1 (XCHGQ <types.NewTuple(typ.BytePtr,types.TypeMem)> val ptr mem)) // Atomic exchanges. (AtomicExchange32 ptr val mem) => (XCHGL val ptr mem) (AtomicExchange64 ptr val mem) => (XCHGQ val ptr mem) // Atomic adds. (AtomicAdd32 ptr val mem) => (AddTupleFirst32 val (XADDLlock val ptr mem)) (AtomicAdd64 ptr val mem) => (AddTupleFirst64 val (XADDQlock val ptr mem)) (Select0 <t> (AddTupleFirst32 val tuple)) => (ADDL val (Select0 <t> tuple)) (Select1 (AddTupleFirst32 _ tuple)) => (Select1 tuple) (Select0 <t> (AddTupleFirst64 val tuple)) => (ADDQ val (Select0 <t> tuple)) (Select1 (AddTupleFirst64 _ tuple)) => (Select1 tuple) // Atomic compare and swap. (AtomicCompareAndSwap32 ptr old new_ mem) => (CMPXCHGLlock ptr old new_ mem) (AtomicCompareAndSwap64 ptr old new_ mem) => (CMPXCHGQlock ptr old new_ mem) // Atomic memory logical operations (old style). (AtomicAnd8 ptr val mem) => (ANDBlock ptr val mem) (AtomicAnd32 ptr val mem) => (ANDLlock ptr val mem) (AtomicOr8 ptr val mem) => (ORBlock ptr val mem) (AtomicOr32 ptr val mem) => (ORLlock ptr val mem) // Atomic memory logical operations (new style). (Atomic(And64|And32|Or64|Or32)value ptr val mem) => (LoweredAtomic(And64|And32|Or64|Or32) ptr val mem) // Write barrier. (WB ...) => (LoweredWB ...) (PanicBounds [kind] x y mem) && boundsABI(kind) == 0 => (LoweredPanicBoundsA [kind] x y mem) (PanicBounds [kind] x y mem) && boundsABI(kind) == 1 => (LoweredPanicBoundsB [kind] x y mem) (PanicBounds [kind] x y mem) && boundsABI(kind) == 2 => (LoweredPanicBoundsC [kind] x y mem) // lowering rotates (RotateLeft8 ...) => (ROLB ...) (RotateLeft16 ...) => (ROLW ...) (RotateLeft32 ...) => (ROLL ...) (RotateLeft64 ...) => (ROLQ ...) // *************************** // Above: lowering rules // Below: optimizations // *************************** // TODO: Should the optimizations be a separate pass? // Fold boolean tests into blocks (NE (TESTB (SETL cmp) (SETL cmp)) yes no) => (LT cmp yes no) (NE (TESTB (SETLE cmp) (SETLE cmp)) yes no) => (LE cmp yes no) (NE (TESTB (SETG cmp) (SETG cmp)) yes no) => (GT cmp yes no) (NE (TESTB (SETGE cmp) (SETGE cmp)) yes no) => (GE cmp yes no) (NE (TESTB (SETEQ cmp) (SETEQ cmp)) yes no) => (EQ cmp yes no) (NE (TESTB (SETNE cmp) (SETNE cmp)) yes no) => (NE cmp yes no) (NE (TESTB (SETB cmp) (SETB cmp)) yes no) => (ULT cmp yes no) (NE (TESTB (SETBE cmp) (SETBE cmp)) yes no) => (ULE cmp yes no) (NE (TESTB (SETA cmp) (SETA cmp)) yes no) => (UGT cmp yes no) (NE (TESTB (SETAE cmp) (SETAE cmp)) yes no) => (UGE cmp yes no) (NE (TESTB (SETO cmp) (SETO cmp)) yes no) => (OS cmp yes no) // Unsigned comparisons to 0/1 (ULT (TEST(Q|L|W|B) x x) yes no) => (First no yes) (UGE (TEST(Q|L|W|B) x x) yes no) => (First yes no) (SETB (TEST(Q|L|W|B) x x)) => (ConstBool [false]) (SETAE (TEST(Q|L|W|B) x x)) => (ConstBool [true]) // x & 1 != 0 -> x & 1 (SETNE (TEST(B|W)const [1] x)) => (AND(L|L)const [1] x) (SETB (BT(L|Q)const [0] x)) => (AND(L|Q)const [1] x) // Recognize bit tests: a&(1<<b) != 0 for b suitably bounded // Note that BTx instructions use the carry bit, so we need to convert tests for zero flag // into tests for carry flags. // ULT and SETB check the carry flag; they are identical to CS and SETCS. Same, mutatis // mutandis, for UGE and SETAE, and CC and SETCC. ((NE|EQ) (TESTL (SHLL (MOVLconst [1]) x) y)) => ((ULT|UGE) (BTL x y)) ((NE|EQ) (TESTQ (SHLQ (MOVQconst [1]) x) y)) => ((ULT|UGE) (BTQ x y)) ((NE|EQ) (TESTLconst [c] x)) && isUint32PowerOfTwo(int64(c)) => ((ULT|UGE) (BTLconst [int8(log32(c))] x)) ((NE|EQ) (TESTQconst [c] x)) && isUint64PowerOfTwo(int64(c)) => ((ULT|UGE) (BTQconst [int8(log32(c))] x)) ((NE|EQ) (TESTQ (MOVQconst [c]) x)) && isUint64PowerOfTwo(c) => ((ULT|UGE) (BTQconst [int8(log64(c))] x)) (SET(NE|EQ) (TESTL (SHLL (MOVLconst [1]) x) y)) => (SET(B|AE) (BTL x y)) (SET(NE|EQ) (TESTQ (SHLQ (MOVQconst [1]) x) y)) => (SET(B|AE) (BTQ x y)) (SET(NE|EQ) (TESTLconst [c] x)) && isUint32PowerOfTwo(int64(c)) => (SET(B|AE) (BTLconst [int8(log32(c))] x)) (SET(NE|EQ) (TESTQconst [c] x)) && isUint64PowerOfTwo(int64(c)) => (SET(B|AE) (BTQconst [int8(log32(c))] x)) (SET(NE|EQ) (TESTQ (MOVQconst [c]) x)) && isUint64PowerOfTwo(c) => (SET(B|AE) (BTQconst [int8(log64(c))] x)) // SET..store variant (SET(NE|EQ)store [off] {sym} ptr (TESTL (SHLL (MOVLconst [1]) x) y) mem) => (SET(B|AE)store [off] {sym} ptr (BTL x y) mem) (SET(NE|EQ)store [off] {sym} ptr (TESTQ (SHLQ (MOVQconst [1]) x) y) mem) => (SET(B|AE)store [off] {sym} ptr (BTQ x y) mem) (SET(NE|EQ)store [off] {sym} ptr (TESTLconst [c] x) mem) && isUint32PowerOfTwo(int64(c)) => (SET(B|AE)store [off] {sym} ptr (BTLconst [int8(log32(c))] x) mem) (SET(NE|EQ)store [off] {sym} ptr (TESTQconst [c] x) mem) && isUint64PowerOfTwo(int64(c)) => (SET(B|AE)store [off] {sym} ptr (BTQconst [int8(log32(c))] x) mem) (SET(NE|EQ)store [off] {sym} ptr (TESTQ (MOVQconst [c]) x) mem) && isUint64PowerOfTwo(c) => (SET(B|AE)store [off] {sym} ptr (BTQconst [int8(log64(c))] x) mem) // Handle bit-testing in the form (a>>b)&1 != 0 by building the above rules // and further combining shifts. (BT(Q|L)const [c] (SHRQconst [d] x)) && (c+d)<64 => (BTQconst [c+d] x) (BT(Q|L)const [c] (SHLQconst [d] x)) && c>d => (BT(Q|L)const [c-d] x) (BT(Q|L)const [0] s:(SHRQ x y)) => (BTQ y x) (BTLconst [c] (SHRLconst [d] x)) && (c+d)<32 => (BTLconst [c+d] x) (BTLconst [c] (SHLLconst [d] x)) && c>d => (BTLconst [c-d] x) (BTLconst [0] s:(SHR(L|XL) x y)) => (BTL y x) // Rewrite a & 1 != 1 into a & 1 == 0. // Among other things, this lets us turn (a>>b)&1 != 1 into a bit test. (SET(NE|EQ) (CMPLconst [1] s:(ANDLconst [1] _))) => (SET(EQ|NE) (CMPLconst [0] s)) (SET(NE|EQ)store [off] {sym} ptr (CMPLconst [1] s:(ANDLconst [1] _)) mem) => (SET(EQ|NE)store [off] {sym} ptr (CMPLconst [0] s) mem) (SET(NE|EQ) (CMPQconst [1] s:(ANDQconst [1] _))) => (SET(EQ|NE) (CMPQconst [0] s)) (SET(NE|EQ)store [off] {sym} ptr (CMPQconst [1] s:(ANDQconst [1] _)) mem) => (SET(EQ|NE)store [off] {sym} ptr (CMPQconst [0] s) mem) // Recognize bit setting (a |= 1<<b) and toggling (a ^= 1<<b) (OR(Q|L) (SHL(Q|L) (MOV(Q|L)const [1]) y) x) => (BTS(Q|L) x y) (XOR(Q|L) (SHL(Q|L) (MOV(Q|L)const [1]) y) x) => (BTC(Q|L) x y) // Note: only convert OR/XOR to BTS/BTC if the constant wouldn't fit in // the constant field of the OR/XOR instruction. See issue 61694. ((OR|XOR)Q (MOVQconst [c]) x) && isUint64PowerOfTwo(c) && uint64(c) >= 1<<31 => (BT(S|C)Qconst [int8(log64(c))] x) // Recognize bit clearing: a &^= 1<<b (AND(Q|L) (NOT(Q|L) (SHL(Q|L) (MOV(Q|L)const [1]) y)) x) => (BTR(Q|L) x y) (ANDN(Q|L) x (SHL(Q|L) (MOV(Q|L)const [1]) y)) => (BTR(Q|L) x y) // Note: only convert AND to BTR if the constant wouldn't fit in // the constant field of the AND instruction. See issue 61694. (ANDQ (MOVQconst [c]) x) && isUint64PowerOfTwo(^c) && uint64(^c) >= 1<<31 => (BTRQconst [int8(log64(^c))] x) // Special-case bit patterns on first/last bit. // generic.rules changes ANDs of high-part/low-part masks into a couple of shifts, // for instance: // x & 0xFFFF0000 -> (x >> 16) << 16 // x & 0x80000000 -> (x >> 31) << 31 // // In case the mask is just one bit (like second example above), it conflicts // with the above rules to detect bit-testing / bit-clearing of first/last bit. // We thus special-case them, by detecting the shift patterns. // Special case resetting first/last bit (SHL(L|Q)const [1] (SHR(L|Q)const [1] x)) => (AND(L|Q)const [-2] x) (SHRLconst [1] (SHLLconst [1] x)) => (ANDLconst [0x7fffffff] x) (SHRQconst [1] (SHLQconst [1] x)) => (BTRQconst [63] x) // Special case testing first/last bit (with double-shift generated by generic.rules) ((SETNE|SETEQ|NE|EQ) (TESTQ z1:(SHLQconst [63] (SHRQconst [63] x)) z2)) && z1==z2 => ((SETB|SETAE|ULT|UGE) (BTQconst [63] x)) ((SETNE|SETEQ|NE|EQ) (TESTL z1:(SHLLconst [31] (SHRQconst [31] x)) z2)) && z1==z2 => ((SETB|SETAE|ULT|UGE) (BTQconst [31] x)) (SET(NE|EQ)store [off] {sym} ptr (TESTQ z1:(SHLQconst [63] (SHRQconst [63] x)) z2) mem) && z1==z2 => (SET(B|AE)store [off] {sym} ptr (BTQconst [63] x) mem) (SET(NE|EQ)store [off] {sym} ptr (TESTL z1:(SHLLconst [31] (SHRLconst [31] x)) z2) mem) && z1==z2 => (SET(B|AE)store [off] {sym} ptr (BTLconst [31] x) mem) ((SETNE|SETEQ|NE|EQ) (TESTQ z1:(SHRQconst [63] (SHLQconst [63] x)) z2)) && z1==z2 => ((SETB|SETAE|ULT|UGE) (BTQconst [0] x)) ((SETNE|SETEQ|NE|EQ) (TESTL z1:(SHRLconst [31] (SHLLconst [31] x)) z2)) && z1==z2 => ((SETB|SETAE|ULT|UGE) (BTLconst [0] x)) (SET(NE|EQ)store [off] {sym} ptr (TESTQ z1:(SHRQconst [63] (SHLQconst [63] x)) z2) mem) && z1==z2 => (SET(B|AE)store [off] {sym} ptr (BTQconst [0] x) mem) (SET(NE|EQ)store [off] {sym} ptr (TESTL z1:(SHRLconst [31] (SHLLconst [31] x)) z2) mem) && z1==z2 => (SET(B|AE)store [off] {sym} ptr (BTLconst [0] x) mem) // Special-case manually testing last bit with "a>>63 != 0" (without "&1") ((SETNE|SETEQ|NE|EQ) (TESTQ z1:(SHRQconst [63] x) z2)) && z1==z2 => ((SETB|SETAE|ULT|UGE) (BTQconst [63] x)) ((SETNE|SETEQ|NE|EQ) (TESTL z1:(SHRLconst [31] x) z2)) && z1==z2 => ((SETB|SETAE|ULT|UGE) (BTLconst [31] x)) (SET(NE|EQ)store [off] {sym} ptr (TESTQ z1:(SHRQconst [63] x) z2) mem) && z1==z2 => (SET(B|AE)store [off] {sym} ptr (BTQconst [63] x) mem) (SET(NE|EQ)store [off] {sym} ptr (TESTL z1:(SHRLconst [31] x) z2) mem) && z1==z2 => (SET(B|AE)store [off] {sym} ptr (BTLconst [31] x) mem) // Fold combinations of bit ops on same bit. An example is math.Copysign(c,-1) (BTSQconst [c] (BTRQconst [c] x)) => (BTSQconst [c] x) (BTSQconst [c] (BTCQconst [c] x)) => (BTSQconst [c] x) (BTRQconst [c] (BTSQconst [c] x)) => (BTRQconst [c] x) (BTRQconst [c] (BTCQconst [c] x)) => (BTRQconst [c] x) // Fold boolean negation into SETcc. (XORLconst [1] (SETNE x)) => (SETEQ x) (XORLconst [1] (SETEQ x)) => (SETNE x) (XORLconst [1] (SETL x)) => (SETGE x) (XORLconst [1] (SETGE x)) => (SETL x) (XORLconst [1] (SETLE x)) => (SETG x) (XORLconst [1] (SETG x)) => (SETLE x) (XORLconst [1] (SETB x)) => (SETAE x) (XORLconst [1] (SETAE x)) => (SETB x) (XORLconst [1] (SETBE x)) => (SETA x) (XORLconst [1] (SETA x)) => (SETBE x) // Special case for floating point - LF/LEF not generated (NE (TESTB (SETGF cmp) (SETGF cmp)) yes no) => (UGT cmp yes no) (NE (TESTB (SETGEF cmp) (SETGEF cmp)) yes no) => (UGE cmp yes no) (NE (TESTB (SETEQF cmp) (SETEQF cmp)) yes no) => (EQF cmp yes no) (NE (TESTB (SETNEF cmp) (SETNEF cmp)) yes no) => (NEF cmp yes no) // Disabled because it interferes with the pattern match above and makes worse code. // (SETNEF x) => (ORQ (SETNE <typ.Int8> x) (SETNAN <typ.Int8> x)) // (SETEQF x) => (ANDQ (SETEQ <typ.Int8> x) (SETORD <typ.Int8> x)) // fold constants into instructions (ADDQ x (MOVQconst <t> [c])) && is32Bit(c) && !t.IsPtr() => (ADDQconst [int32(c)] x) (ADDQ x (MOVLconst [c])) => (ADDQconst [c] x) (ADDL x (MOVLconst [c])) => (ADDLconst [c] x) (SUBQ x (MOVQconst [c])) && is32Bit(c) => (SUBQconst x [int32(c)]) (SUBQ (MOVQconst [c]) x) && is32Bit(c) => (NEGQ (SUBQconst <v.Type> x [int32(c)])) (SUBL x (MOVLconst [c])) => (SUBLconst x [c]) (SUBL (MOVLconst [c]) x) => (NEGL (SUBLconst <v.Type> x [c])) (MULQ x (MOVQconst [c])) && is32Bit(c) => (MULQconst [int32(c)] x) (MULL x (MOVLconst [c])) => (MULLconst [c] x) (ANDQ x (MOVQconst [c])) && is32Bit(c) => (ANDQconst [int32(c)] x) (ANDL x (MOVLconst [c])) => (ANDLconst [c] x) (AND(L|Q)const [c] (AND(L|Q)const [d] x)) => (AND(L|Q)const [c & d] x) (XOR(L|Q)const [c] (XOR(L|Q)const [d] x)) => (XOR(L|Q)const [c ^ d] x) (OR(L|Q)const [c] (OR(L|Q)const [d] x)) => (OR(L|Q)const [c | d] x) (MULLconst [c] (MULLconst [d] x)) => (MULLconst [c * d] x) (MULQconst [c] (MULQconst [d] x)) && is32Bit(int64(c)*int64(d)) => (MULQconst [c * d] x) (ORQ x (MOVQconst [c])) && is32Bit(c) => (ORQconst [int32(c)] x) (ORQ x (MOVLconst [c])) => (ORQconst [c] x) (ORL x (MOVLconst [c])) => (ORLconst [c] x) (XORQ x (MOVQconst [c])) && is32Bit(c) => (XORQconst [int32(c)] x) (XORL x (MOVLconst [c])) => (XORLconst [c] x) (SHLQ x (MOV(Q|L)const [c])) => (SHLQconst [int8(c&63)] x) (SHLL x (MOV(Q|L)const [c])) => (SHLLconst [int8(c&31)] x) (SHRQ x (MOV(Q|L)const [c])) => (SHRQconst [int8(c&63)] x) (SHRL x (MOV(Q|L)const [c])) => (SHRLconst [int8(c&31)] x) (SHRW x (MOV(Q|L)const [c])) && c&31 < 16 => (SHRWconst [int8(c&31)] x) (SHRW _ (MOV(Q|L)const [c])) && c&31 >= 16 => (MOVLconst [0]) (SHRB x (MOV(Q|L)const [c])) && c&31 < 8 => (SHRBconst [int8(c&31)] x) (SHRB _ (MOV(Q|L)const [c])) && c&31 >= 8 => (MOVLconst [0]) (SARQ x (MOV(Q|L)const [c])) => (SARQconst [int8(c&63)] x) (SARL x (MOV(Q|L)const [c])) => (SARLconst [int8(c&31)] x) (SARW x (MOV(Q|L)const [c])) => (SARWconst [int8(min(int64(c)&31,15))] x) (SARB x (MOV(Q|L)const [c])) => (SARBconst [int8(min(int64(c)&31,7))] x) // Operations which don't affect the low 6/5 bits of the shift amount are NOPs. ((SHLQ|SHRQ|SARQ) x (ADDQconst [c] y)) && c & 63 == 0 => ((SHLQ|SHRQ|SARQ) x y) ((SHLQ|SHRQ|SARQ) x (NEGQ <t> (ADDQconst [c] y))) && c & 63 == 0 => ((SHLQ|SHRQ|SARQ) x (NEGQ <t> y)) ((SHLQ|SHRQ|SARQ) x (ANDQconst [c] y)) && c & 63 == 63 => ((SHLQ|SHRQ|SARQ) x y) ((SHLQ|SHRQ|SARQ) x (NEGQ <t> (ANDQconst [c] y))) && c & 63 == 63 => ((SHLQ|SHRQ|SARQ) x (NEGQ <t> y)) ((SHLL|SHRL|SARL) x (ADDQconst [c] y)) && c & 31 == 0 => ((SHLL|SHRL|SARL) x y) ((SHLL|SHRL|SARL) x (NEGQ <t> (ADDQconst [c] y))) && c & 31 == 0 => ((SHLL|SHRL|SARL) x (NEGQ <t> y)) ((SHLL|SHRL|SARL) x (ANDQconst [c] y)) && c & 31 == 31 => ((SHLL|SHRL|SARL) x y) ((SHLL|SHRL|SARL) x (NEGQ <t> (ANDQconst [c] y))) && c & 31 == 31 => ((SHLL|SHRL|SARL) x (NEGQ <t> y)) ((SHLQ|SHRQ|SARQ) x (ADDLconst [c] y)) && c & 63 == 0 => ((SHLQ|SHRQ|SARQ) x y) ((SHLQ|SHRQ|SARQ) x (NEGL <t> (ADDLconst [c] y))) && c & 63 == 0 => ((SHLQ|SHRQ|SARQ) x (NEGL <t> y)) ((SHLQ|SHRQ|SARQ) x (ANDLconst [c] y)) && c & 63 == 63 => ((SHLQ|SHRQ|SARQ) x y) ((SHLQ|SHRQ|SARQ) x (NEGL <t> (ANDLconst [c] y))) && c & 63 == 63 => ((SHLQ|SHRQ|SARQ) x (NEGL <t> y)) ((SHLL|SHRL|SARL) x (ADDLconst [c] y)) && c & 31 == 0 => ((SHLL|SHRL|SARL) x y) ((SHLL|SHRL|SARL) x (NEGL <t> (ADDLconst [c] y))) && c & 31 == 0 => ((SHLL|SHRL|SARL) x (NEGL <t> y)) ((SHLL|SHRL|SARL) x (ANDLconst [c] y)) && c & 31 == 31 => ((SHLL|SHRL|SARL) x y) ((SHLL|SHRL|SARL) x (NEGL <t> (ANDLconst [c] y))) && c & 31 == 31 => ((SHLL|SHRL|SARL) x (NEGL <t> y)) // rotate left negative = rotate right (ROLQ x (NEG(Q|L) y)) => (RORQ x y) (ROLL x (NEG(Q|L) y)) => (RORL x y) (ROLW x (NEG(Q|L) y)) => (RORW x y) (ROLB x (NEG(Q|L) y)) => (RORB x y) // rotate right negative = rotate left (RORQ x (NEG(Q|L) y)) => (ROLQ x y) (RORL x (NEG(Q|L) y)) => (ROLL x y) (RORW x (NEG(Q|L) y)) => (ROLW x y) (RORB x (NEG(Q|L) y)) => (ROLB x y) // rotate by constants (ROLQ x (MOV(Q|L)const [c])) => (ROLQconst [int8(c&63)] x) (ROLL x (MOV(Q|L)const [c])) => (ROLLconst [int8(c&31)] x) (ROLW x (MOV(Q|L)const [c])) => (ROLWconst [int8(c&15)] x) (ROLB x (MOV(Q|L)const [c])) => (ROLBconst [int8(c&7) ] x) (RORQ x (MOV(Q|L)const [c])) => (ROLQconst [int8((-c)&63)] x) (RORL x (MOV(Q|L)const [c])) => (ROLLconst [int8((-c)&31)] x) (RORW x (MOV(Q|L)const [c])) => (ROLWconst [int8((-c)&15)] x) (RORB x (MOV(Q|L)const [c])) => (ROLBconst [int8((-c)&7) ] x) // Constant shift simplifications ((SHLQ|SHRQ|SARQ)const x [0]) => x ((SHLL|SHRL|SARL)const x [0]) => x ((SHRW|SARW)const x [0]) => x ((SHRB|SARB)const x [0]) => x ((ROLQ|ROLL|ROLW|ROLB)const x [0]) => x // Multi-register shifts (ORQ (SH(R|L)Q lo bits) (SH(L|R)Q hi (NEGQ bits))) => (SH(R|L)DQ lo hi bits) (ORQ (SH(R|L)XQ lo bits) (SH(L|R)XQ hi (NEGQ bits))) => (SH(R|L)DQ lo hi bits) // Note: the word and byte shifts keep the low 5 bits (not the low 4 or 3 bits) // because the x86 instructions are defined to use all 5 bits of the shift even // for the small shifts. I don't think we'll ever generate a weird shift (e.g. // (SHRW x (MOVLconst [24])), but just in case. (CMPQ x (MOVQconst [c])) && is32Bit(c) => (CMPQconst x [int32(c)]) (CMPQ (MOVQconst [c]) x) && is32Bit(c) => (InvertFlags (CMPQconst x [int32(c)])) (CMPL x (MOVLconst [c])) => (CMPLconst x [c]) (CMPL (MOVLconst [c]) x) => (InvertFlags (CMPLconst x [c])) (CMPW x (MOVLconst [c])) => (CMPWconst x [int16(c)]) (CMPW (MOVLconst [c]) x) => (InvertFlags (CMPWconst x [int16(c)])) (CMPB x (MOVLconst [c])) => (CMPBconst x [int8(c)]) (CMPB (MOVLconst [c]) x) => (InvertFlags (CMPBconst x [int8(c)])) // Canonicalize the order of arguments to comparisons - helps with CSE. (CMP(Q|L|W|B) x y) && canonLessThan(x,y) => (InvertFlags (CMP(Q|L|W|B) y x)) // Using MOVZX instead of AND is cheaper. (AND(Q|L)const [ 0xFF] x) => (MOVBQZX x) (AND(Q|L)const [0xFFFF] x) => (MOVWQZX x) // This rule is currently invalid because 0xFFFFFFFF is not representable by a signed int32. // Commenting out for now, because it also can't trigger because of the is32bit guard on the // ANDQconst lowering-rule, above, prevents 0xFFFFFFFF from matching (for the same reason) // Using an alternate form of this rule segfaults some binaries because of // adverse interactions with other passes. // (ANDQconst [0xFFFFFFFF] x) => (MOVLQZX x) // strength reduction // Assumes that the following costs from https://gmplib.org/~tege/x86-timing.pdf: // 1 - addq, shlq, leaq, negq, subq // 3 - imulq // This limits the rewrites to two instructions. // Note that negq always operates in-place, // which can require a register-register move // to preserve the original value, // so it must be used with care. (MUL(Q|L)const [-9] x) => (NEG(Q|L) (LEA(Q|L)8 <v.Type> x x)) (MUL(Q|L)const [-5] x) => (NEG(Q|L) (LEA(Q|L)4 <v.Type> x x)) (MUL(Q|L)const [-3] x) => (NEG(Q|L) (LEA(Q|L)2 <v.Type> x x)) (MUL(Q|L)const [-1] x) => (NEG(Q|L) x) (MUL(Q|L)const [ 0] _) => (MOV(Q|L)const [0]) (MUL(Q|L)const [ 1] x) => x (MUL(Q|L)const [ 3] x) => (LEA(Q|L)2 x x) (MUL(Q|L)const [ 5] x) => (LEA(Q|L)4 x x) (MUL(Q|L)const [ 7] x) => (LEA(Q|L)2 x (LEA(Q|L)2 <v.Type> x x)) (MUL(Q|L)const [ 9] x) => (LEA(Q|L)8 x x) (MUL(Q|L)const [11] x) => (LEA(Q|L)2 x (LEA(Q|L)4 <v.Type> x x)) (MUL(Q|L)const [13] x) => (LEA(Q|L)4 x (LEA(Q|L)2 <v.Type> x x)) (MUL(Q|L)const [19] x) => (LEA(Q|L)2 x (LEA(Q|L)8 <v.Type> x x)) (MUL(Q|L)const [21] x) => (LEA(Q|L)4 x (LEA(Q|L)4 <v.Type> x x)) (MUL(Q|L)const [25] x) => (LEA(Q|L)8 x (LEA(Q|L)2 <v.Type> x x)) (MUL(Q|L)const [27] x) => (LEA(Q|L)8 (LEA(Q|L)2 <v.Type> x x) (LEA(Q|L)2 <v.Type> x x)) (MUL(Q|L)const [37] x) => (LEA(Q|L)4 x (LEA(Q|L)8 <v.Type> x x)) (MUL(Q|L)const [41] x) => (LEA(Q|L)8 x (LEA(Q|L)4 <v.Type> x x)) (MUL(Q|L)const [45] x) => (LEA(Q|L)8 (LEA(Q|L)4 <v.Type> x x) (LEA(Q|L)4 <v.Type> x x)) (MUL(Q|L)const [73] x) => (LEA(Q|L)8 x (LEA(Q|L)8 <v.Type> x x)) (MUL(Q|L)const [81] x) => (LEA(Q|L)8 (LEA(Q|L)8 <v.Type> x x) (LEA(Q|L)8 <v.Type> x x)) (MUL(Q|L)const [c] x) && isPowerOfTwo64(int64(c)+1) && c >= 15 => (SUB(Q|L) (SHL(Q|L)const <v.Type> [int8(log64(int64(c)+1))] x) x) (MUL(Q|L)const [c] x) && isPowerOfTwo32(c-1) && c >= 17 => (LEA(Q|L)1 (SHL(Q|L)const <v.Type> [int8(log32(c-1))] x) x) (MUL(Q|L)const [c] x) && isPowerOfTwo32(c-2) && c >= 34 => (LEA(Q|L)2 (SHL(Q|L)const <v.Type> [int8(log32(c-2))] x) x) (MUL(Q|L)const [c] x) && isPowerOfTwo32(c-4) && c >= 68 => (LEA(Q|L)4 (SHL(Q|L)const <v.Type> [int8(log32(c-4))] x) x) (MUL(Q|L)const [c] x) && isPowerOfTwo32(c-8) && c >= 136 => (LEA(Q|L)8 (SHL(Q|L)const <v.Type> [int8(log32(c-8))] x) x) (MUL(Q|L)const [c] x) && c%3 == 0 && isPowerOfTwo32(c/3) => (SHL(Q|L)const [int8(log32(c/3))] (LEA(Q|L)2 <v.Type> x x)) (MUL(Q|L)const [c] x) && c%5 == 0 && isPowerOfTwo32(c/5) => (SHL(Q|L)const [int8(log32(c/5))] (LEA(Q|L)4 <v.Type> x x)) (MUL(Q|L)const [c] x) && c%9 == 0 && isPowerOfTwo32(c/9) => (SHL(Q|L)const [int8(log32(c/9))] (LEA(Q|L)8 <v.Type> x x)) // combine add/shift into LEAQ/LEAL (ADD(L|Q) x (SHL(L|Q)const [3] y)) => (LEA(L|Q)8 x y) (ADD(L|Q) x (SHL(L|Q)const [2] y)) => (LEA(L|Q)4 x y) (ADD(L|Q) x (SHL(L|Q)const [1] y)) => (LEA(L|Q)2 x y) (ADD(L|Q) x (ADD(L|Q) y y)) => (LEA(L|Q)2 x y) (ADD(L|Q) x (ADD(L|Q) x y)) => (LEA(L|Q)2 y x) // combine ADDQ/ADDQconst into LEAQ1/LEAL1 (ADD(Q|L)const [c] (ADD(Q|L) x y)) => (LEA(Q|L)1 [c] x y) (ADD(Q|L) (ADD(Q|L)const [c] x) y) => (LEA(Q|L)1 [c] x y) (ADD(Q|L)const [c] (SHL(Q|L)const [1] x)) => (LEA(Q|L)1 [c] x x) // fold ADDQ/ADDL into LEAQ/LEAL (ADD(Q|L)const [c] (LEA(Q|L) [d] {s} x)) && is32Bit(int64(c)+int64(d)) => (LEA(Q|L) [c+d] {s} x) (LEA(Q|L) [c] {s} (ADD(Q|L)const [d] x)) && is32Bit(int64(c)+int64(d)) => (LEA(Q|L) [c+d] {s} x) (LEA(Q|L) [c] {s} (ADD(Q|L) x y)) && x.Op != OpSB && y.Op != OpSB => (LEA(Q|L)1 [c] {s} x y) (ADD(Q|L) x (LEA(Q|L) [c] {s} y)) && x.Op != OpSB && y.Op != OpSB => (LEA(Q|L)1 [c] {s} x y) // fold ADDQconst/ADDLconst into LEAQx/LEALx (ADD(Q|L)const [c] (LEA(Q|L)1 [d] {s} x y)) && is32Bit(int64(c)+int64(d)) => (LEA(Q|L)1 [c+d] {s} x y) (ADD(Q|L)const [c] (LEA(Q|L)2 [d] {s} x y)) && is32Bit(int64(c)+int64(d)) => (LEA(Q|L)2 [c+d] {s} x y) (ADD(Q|L)const [c] (LEA(Q|L)4 [d] {s} x y)) && is32Bit(int64(c)+int64(d)) => (LEA(Q|L)4 [c+d] {s} x y) (ADD(Q|L)const [c] (LEA(Q|L)8 [d] {s} x y)) && is32Bit(int64(c)+int64(d)) => (LEA(Q|L)8 [c+d] {s} x y) (LEA(Q|L)1 [c] {s} (ADD(Q|L)const [d] x) y) && is32Bit(int64(c)+int64(d)) && x.Op != OpSB => (LEA(Q|L)1 [c+d] {s} x y) (LEA(Q|L)2 [c] {s} (ADD(Q|L)const [d] x) y) && is32Bit(int64(c)+int64(d)) && x.Op != OpSB => (LEA(Q|L)2 [c+d] {s} x y) (LEA(Q|L)2 [c] {s} x (ADD(Q|L)const [d] y)) && is32Bit(int64(c)+2*int64(d)) && y.Op != OpSB => (LEA(Q|L)2 [c+2*d] {s} x y) (LEA(Q|L)4 [c] {s} (ADD(Q|L)const [d] x) y) && is32Bit(int64(c)+int64(d)) && x.Op != OpSB => (LEA(Q|L)4 [c+d] {s} x y) (LEA(Q|L)4 [c] {s} x (ADD(Q|L)const [d] y)) && is32Bit(int64(c)+4*int64(d)) && y.Op != OpSB => (LEA(Q|L)4 [c+4*d] {s} x y) (LEA(Q|L)8 [c] {s} (ADD(Q|L)const [d] x) y) && is32Bit(int64(c)+int64(d)) && x.Op != OpSB => (LEA(Q|L)8 [c+d] {s} x y) (LEA(Q|L)8 [c] {s} x (ADD(Q|L)const [d] y)) && is32Bit(int64(c)+8*int64(d)) && y.Op != OpSB => (LEA(Q|L)8 [c+8*d] {s} x y) // fold shifts into LEAQx/LEALx (LEA(Q|L)1 [c] {s} x (SHL(Q|L)const [1] y)) => (LEA(Q|L)2 [c] {s} x y) (LEA(Q|L)1 [c] {s} x (SHL(Q|L)const [2] y)) => (LEA(Q|L)4 [c] {s} x y) (LEA(Q|L)1 [c] {s} x (SHL(Q|L)const [3] y)) => (LEA(Q|L)8 [c] {s} x y) (LEA(Q|L)2 [c] {s} x (SHL(Q|L)const [1] y)) => (LEA(Q|L)4 [c] {s} x y) (LEA(Q|L)2 [c] {s} x (SHL(Q|L)const [2] y)) => (LEA(Q|L)8 [c] {s} x y) (LEA(Q|L)4 [c] {s} x (SHL(Q|L)const [1] y)) => (LEA(Q|L)8 [c] {s} x y) // reverse ordering of compare instruction (SETL (InvertFlags x)) => (SETG x) (SETG (InvertFlags x)) => (SETL x) (SETB (InvertFlags x)) => (SETA x) (SETA (InvertFlags x)) => (SETB x) (SETLE (InvertFlags x)) => (SETGE x) (SETGE (InvertFlags x)) => (SETLE x) (SETBE (InvertFlags x)) => (SETAE x) (SETAE (InvertFlags x)) => (SETBE x) (SETEQ (InvertFlags x)) => (SETEQ x) (SETNE (InvertFlags x)) => (SETNE x) (SETLstore [off] {sym} ptr (InvertFlags x) mem) => (SETGstore [off] {sym} ptr x mem) (SETGstore [off] {sym} ptr (InvertFlags x) mem) => (SETLstore [off] {sym} ptr x mem) (SETBstore [off] {sym} ptr (InvertFlags x) mem) => (SETAstore [off] {sym} ptr x mem) (SETAstore [off] {sym} ptr (InvertFlags x) mem) => (SETBstore [off] {sym} ptr x mem) (SETLEstore [off] {sym} ptr (InvertFlags x) mem) => (SETGEstore [off] {sym} ptr x mem) (SETGEstore [off] {sym} ptr (InvertFlags x) mem) => (SETLEstore [off] {sym} ptr x mem) (SETBEstore [off] {sym} ptr (InvertFlags x) mem) => (SETAEstore [off] {sym} ptr x mem) (SETAEstore [off] {sym} ptr (InvertFlags x) mem) => (SETBEstore [off] {sym} ptr x mem) (SETEQstore [off] {sym} ptr (InvertFlags x) mem) => (SETEQstore [off] {sym} ptr x mem) (SETNEstore [off] {sym} ptr (InvertFlags x) mem) => (SETNEstore [off] {sym} ptr x mem) // sign extended loads // Note: The combined instruction must end up in the same block // as the original load. If not, we end up making a value with // memory type live in two different blocks, which can lead to // multiple memory values alive simultaneously. // Make sure we don't combine these ops if the load has another use. // This prevents a single load from being split into multiple loads // which then might return different values. See test/atomicload.go. (MOVBQSX x:(MOVBload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVBQSXload <v.Type> [off] {sym} ptr mem) (MOVBQSX x:(MOVWload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVBQSXload <v.Type> [off] {sym} ptr mem) (MOVBQSX x:(MOVLload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVBQSXload <v.Type> [off] {sym} ptr mem) (MOVBQSX x:(MOVQload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVBQSXload <v.Type> [off] {sym} ptr mem) (MOVBQZX x:(MOVBload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVBload <v.Type> [off] {sym} ptr mem) (MOVBQZX x:(MOVWload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVBload <v.Type> [off] {sym} ptr mem) (MOVBQZX x:(MOVLload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVBload <v.Type> [off] {sym} ptr mem) (MOVBQZX x:(MOVQload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVBload <v.Type> [off] {sym} ptr mem) (MOVWQSX x:(MOVWload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVWQSXload <v.Type> [off] {sym} ptr mem) (MOVWQSX x:(MOVLload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVWQSXload <v.Type> [off] {sym} ptr mem) (MOVWQSX x:(MOVQload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVWQSXload <v.Type> [off] {sym} ptr mem) (MOVWQZX x:(MOVWload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVWload <v.Type> [off] {sym} ptr mem) (MOVWQZX x:(MOVLload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVWload <v.Type> [off] {sym} ptr mem) (MOVWQZX x:(MOVQload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVWload <v.Type> [off] {sym} ptr mem) (MOVLQSX x:(MOVLload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVLQSXload <v.Type> [off] {sym} ptr mem) (MOVLQSX x:(MOVQload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVLQSXload <v.Type> [off] {sym} ptr mem) (MOVLQZX x:(MOVLload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVLload <v.Type> [off] {sym} ptr mem) (MOVLQZX x:(MOVQload [off] {sym} ptr mem)) && x.Uses == 1 && clobber(x) => @x.Block (MOVLload <v.Type> [off] {sym} ptr mem) // replace load from same location as preceding store with zero/sign extension (or copy in case of full width) (MOVBload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVBQZX x) (MOVWload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVWQZX x) (MOVLload [off] {sym} ptr (MOVLstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVLQZX x) (MOVQload [off] {sym} ptr (MOVQstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => x (MOVBQSXload [off] {sym} ptr (MOVBstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVBQSX x) (MOVWQSXload [off] {sym} ptr (MOVWstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVWQSX x) (MOVLQSXload [off] {sym} ptr (MOVLstore [off2] {sym2} ptr2 x _)) && sym == sym2 && off == off2 && isSamePtr(ptr, ptr2) => (MOVLQSX x) // Fold extensions and ANDs together. (MOVBQZX (ANDLconst [c] x)) => (ANDLconst [c & 0xff] x) (MOVWQZX (ANDLconst [c] x)) => (ANDLconst [c & 0xffff] x) (MOVLQZX (ANDLconst [c] x)) => (ANDLconst [c] x) (MOVBQSX (ANDLconst [c] x)) && c & 0x80 == 0 => (ANDLconst [c & 0x7f] x) (MOVWQSX (ANDLconst [c] x)) && c & 0x8000 == 0 => (ANDLconst [c & 0x7fff] x) (MOVLQSX (ANDLconst [c] x)) && uint32(c) & 0x80000000 == 0 => (ANDLconst [c & 0x7fffffff] x) // Don't extend before storing (MOVLstore [off] {sym} ptr (MOVLQSX x) mem) => (MOVLstore [off] {sym} ptr x mem) (MOVWstore [off] {sym} ptr (MOVWQSX x) mem) => (MOVWstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr (MOVBQSX x) mem) => (MOVBstore [off] {sym} ptr x mem) (MOVLstore [off] {sym} ptr (MOVLQZX x) mem) => (MOVLstore [off] {sym} ptr x mem) (MOVWstore [off] {sym} ptr (MOVWQZX x) mem) => (MOVWstore [off] {sym} ptr x mem) (MOVBstore [off] {sym} ptr (MOVBQZX x) mem) => (MOVBstore [off] {sym} ptr x mem) // fold constants into memory operations // Note that this is not always a good idea because if not all the uses of // the ADDQconst get eliminated, we still have to compute the ADDQconst and we now // have potentially two live values (ptr and (ADDQconst [off] ptr)) instead of one. // Nevertheless, let's do it! (MOV(Q|L|W|B|SS|SD|O)load [off1] {sym} (ADDQconst [off2] ptr) mem) && is32Bit(int64(off1)+int64(off2)) => (MOV(Q|L|W|B|SS|SD|O)load [off1+off2] {sym} ptr mem) (MOV(Q|L|W|B|SS|SD|O)store [off1] {sym} (ADDQconst [off2] ptr) val mem) && is32Bit(int64(off1)+int64(off2)) => (MOV(Q|L|W|B|SS|SD|O)store [off1+off2] {sym} ptr val mem) (SET(L|G|B|A|LE|GE|BE|AE|EQ|NE)store [off1] {sym} (ADDQconst [off2] base) val mem) && is32Bit(int64(off1)+int64(off2)) => (SET(L|G|B|A|LE|GE|BE|AE|EQ|NE)store [off1+off2] {sym} base val mem) ((ADD|SUB|AND|OR|XOR)Qload [off1] {sym} val (ADDQconst [off2] base) mem) && is32Bit(int64(off1)+int64(off2)) => ((ADD|SUB|AND|OR|XOR)Qload [off1+off2] {sym} val base mem) ((ADD|SUB|AND|OR|XOR)Lload [off1] {sym} val (ADDQconst [off2] base) mem) && is32Bit(int64(off1)+int64(off2)) => ((ADD|SUB|AND|OR|XOR)Lload [off1+off2] {sym} val base mem) (CMP(Q|L|W|B)load [off1] {sym} (ADDQconst [off2] base) val mem) && is32Bit(int64(off1)+int64(off2)) => (CMP(Q|L|W|B)load [off1+off2] {sym} base val mem) (CMP(Q|L|W|B)constload [valoff1] {sym} (ADDQconst [off2] base) mem) && ValAndOff(valoff1).canAdd32(off2) => (CMP(Q|L|W|B)constload [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) ((ADD|SUB|MUL|DIV)SSload [off1] {sym} val (ADDQconst [off2] base) mem) && is32Bit(int64(off1)+int64(off2)) => ((ADD|SUB|MUL|DIV)SSload [off1+off2] {sym} val base mem) ((ADD|SUB|MUL|DIV)SDload [off1] {sym} val (ADDQconst [off2] base) mem) && is32Bit(int64(off1)+int64(off2)) => ((ADD|SUB|MUL|DIV)SDload [off1+off2] {sym} val base mem) ((ADD|AND|OR|XOR)Qconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) && ValAndOff(valoff1).canAdd32(off2) => ((ADD|AND|OR|XOR)Qconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) ((ADD|AND|OR|XOR)Lconstmodify [valoff1] {sym} (ADDQconst [off2] base) mem) && ValAndOff(valoff1).canAdd32(off2) => ((ADD|AND|OR|XOR)Lconstmodify [ValAndOff(valoff1).addOffset32(off2)] {sym} base mem) ((ADD|SUB|AND|OR|XOR)Qmodify [off1] {sym} (ADDQconst [off2] base) val mem) && is32Bit(int64(off1)+int64(off2)) => ((ADD|SUB|AND|OR|XOR)Qmodify [off1+off2] {sym} base val mem) ((ADD|SUB|AND|OR|XOR)Lmodify [off1] {sym} (ADDQconst [off2] base) val mem) && is32Bit(int64(off1)+int64(off2)) => ((ADD|SUB|AND|OR|XOR)Lmodify [off1+off2] {sym} base val mem) // Fold constants into stores. (MOVQstore [off] {sym} ptr (MOVQconst [c]) mem) && validVal(c) => (MOVQstoreconst [makeValAndOff(int32(c),off)] {sym} ptr mem) (MOVLstore [off] {sym} ptr (MOV(L|Q)const [c]) mem) => (MOVLstoreconst [makeValAndOff(int32(c),off)] {sym} ptr mem) (MOVWstore [off] {sym} ptr (MOV(L|Q)const [c]) mem) => (MOVWstoreconst [makeValAndOff(int32(int16(c)),off)] {sym} ptr mem) (MOVBstore [off] {sym} ptr (MOV(L|Q)const [c]) mem) => (MOVBstoreconst [makeValAndOff(int32(int8(c)),off)] {sym} ptr mem) // Fold address offsets into constant stores. (MOV(Q|L|W|B|O)storeconst [sc] {s} (ADDQconst [off] ptr) mem) && ValAndOff(sc).canAdd32(off) => (MOV(Q|L|W|B|O)storeconst [ValAndOff(sc).addOffset32(off)] {s} ptr mem) // We need to fold LEAQ into the MOVx ops so that the live variable analysis knows // what variables are being read/written by the ops. (MOV(Q|L|W|B|SS|SD|O|BQSX|WQSX|LQSX)load [off1] {sym1} (LEAQ [off2] {sym2} base) mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (MOV(Q|L|W|B|SS|SD|O|BQSX|WQSX|LQSX)load [off1+off2] {mergeSym(sym1,sym2)} base mem) (MOV(Q|L|W|B|SS|SD|O)store [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (MOV(Q|L|W|B|SS|SD|O)store [off1+off2] {mergeSym(sym1,sym2)} base val mem) (MOV(Q|L|W|B|O)storeconst [sc] {sym1} (LEAQ [off] {sym2} ptr) mem) && canMergeSym(sym1, sym2) && ValAndOff(sc).canAdd32(off) => (MOV(Q|L|W|B|O)storeconst [ValAndOff(sc).addOffset32(off)] {mergeSym(sym1, sym2)} ptr mem) (SET(L|G|B|A|LE|GE|BE|AE|EQ|NE)store [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (SET(L|G|B|A|LE|GE|BE|AE|EQ|NE)store [off1+off2] {mergeSym(sym1,sym2)} base val mem) ((ADD|SUB|AND|OR|XOR)Qload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => ((ADD|SUB|AND|OR|XOR)Qload [off1+off2] {mergeSym(sym1,sym2)} val base mem) ((ADD|SUB|AND|OR|XOR)Lload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => ((ADD|SUB|AND|OR|XOR)Lload [off1+off2] {mergeSym(sym1,sym2)} val base mem) (CMP(Q|L|W|B)load [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (CMP(Q|L|W|B)load [off1+off2] {mergeSym(sym1,sym2)} base val mem) (CMP(Q|L|W|B)constload [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) && ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) => (CMP(Q|L|W|B)constload [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) ((ADD|SUB|MUL|DIV)SSload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => ((ADD|SUB|MUL|DIV)SSload [off1+off2] {mergeSym(sym1,sym2)} val base mem) ((ADD|SUB|MUL|DIV)SDload [off1] {sym1} val (LEAQ [off2] {sym2} base) mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => ((ADD|SUB|MUL|DIV)SDload [off1+off2] {mergeSym(sym1,sym2)} val base mem) ((ADD|AND|OR|XOR)Qconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) && ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) => ((ADD|AND|OR|XOR)Qconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) ((ADD|AND|OR|XOR)Lconstmodify [valoff1] {sym1} (LEAQ [off2] {sym2} base) mem) && ValAndOff(valoff1).canAdd32(off2) && canMergeSym(sym1, sym2) => ((ADD|AND|OR|XOR)Lconstmodify [ValAndOff(valoff1).addOffset32(off2)] {mergeSym(sym1,sym2)} base mem) ((ADD|SUB|AND|OR|XOR)Qmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => ((ADD|SUB|AND|OR|XOR)Qmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) ((ADD|SUB|AND|OR|XOR)Lmodify [off1] {sym1} (LEAQ [off2] {sym2} base) val mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => ((ADD|SUB|AND|OR|XOR)Lmodify [off1+off2] {mergeSym(sym1,sym2)} base val mem) // fold LEAQs together (LEAQ [off1] {sym1} (LEAQ [off2] {sym2} x)) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (LEAQ [off1+off2] {mergeSym(sym1,sym2)} x) // LEAQ into LEAQ1 (LEAQ1 [off1] {sym1} (LEAQ [off2] {sym2} x) y) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB => (LEAQ1 [off1+off2] {mergeSym(sym1,sym2)} x y) // LEAQ1 into LEAQ (LEAQ [off1] {sym1} (LEAQ1 [off2] {sym2} x y)) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (LEAQ1 [off1+off2] {mergeSym(sym1,sym2)} x y) // LEAQ into LEAQ[248] (LEAQ2 [off1] {sym1} (LEAQ [off2] {sym2} x) y) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB => (LEAQ2 [off1+off2] {mergeSym(sym1,sym2)} x y) (LEAQ4 [off1] {sym1} (LEAQ [off2] {sym2} x) y) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB => (LEAQ4 [off1+off2] {mergeSym(sym1,sym2)} x y) (LEAQ8 [off1] {sym1} (LEAQ [off2] {sym2} x) y) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && x.Op != OpSB => (LEAQ8 [off1+off2] {mergeSym(sym1,sym2)} x y) // LEAQ[248] into LEAQ (LEAQ [off1] {sym1} (LEAQ2 [off2] {sym2} x y)) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (LEAQ2 [off1+off2] {mergeSym(sym1,sym2)} x y) (LEAQ [off1] {sym1} (LEAQ4 [off2] {sym2} x y)) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (LEAQ4 [off1+off2] {mergeSym(sym1,sym2)} x y) (LEAQ [off1] {sym1} (LEAQ8 [off2] {sym2} x y)) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (LEAQ8 [off1+off2] {mergeSym(sym1,sym2)} x y) // LEAQ[1248] into LEAQ[1248]. Only some such merges are possible. (LEAQ1 [off1] {sym1} x (LEAQ1 [off2] {sym2} y y)) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (LEAQ2 [off1+off2] {mergeSym(sym1, sym2)} x y) (LEAQ1 [off1] {sym1} x (LEAQ1 [off2] {sym2} x y)) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (LEAQ2 [off1+off2] {mergeSym(sym1, sym2)} y x) (LEAQ2 [off1] {sym1} x (LEAQ1 [off2] {sym2} y y)) && is32Bit(int64(off1)+2*int64(off2)) && sym2 == nil => (LEAQ4 [off1+2*off2] {sym1} x y) (LEAQ4 [off1] {sym1} x (LEAQ1 [off2] {sym2} y y)) && is32Bit(int64(off1)+4*int64(off2)) && sym2 == nil => (LEAQ8 [off1+4*off2] {sym1} x y) // TODO: more? // Lower LEAQ2/4/8 when the offset is a constant (LEAQ2 [off] {sym} x (MOV(Q|L)const [scale])) && is32Bit(int64(off)+int64(scale)*2) => (LEAQ [off+int32(scale)*2] {sym} x) (LEAQ4 [off] {sym} x (MOV(Q|L)const [scale])) && is32Bit(int64(off)+int64(scale)*4) => (LEAQ [off+int32(scale)*4] {sym} x) (LEAQ8 [off] {sym} x (MOV(Q|L)const [scale])) && is32Bit(int64(off)+int64(scale)*8) => (LEAQ [off+int32(scale)*8] {sym} x) // Absorb InvertFlags into branches. (LT (InvertFlags cmp) yes no) => (GT cmp yes no) (GT (InvertFlags cmp) yes no) => (LT cmp yes no) (LE (InvertFlags cmp) yes no) => (GE cmp yes no) (GE (InvertFlags cmp) yes no) => (LE cmp yes no) (ULT (InvertFlags cmp) yes no) => (UGT cmp yes no) (UGT (InvertFlags cmp) yes no) => (ULT cmp yes no) (ULE (InvertFlags cmp) yes no) => (UGE cmp yes no) (UGE (InvertFlags cmp) yes no) => (ULE cmp yes no) (EQ (InvertFlags cmp) yes no) => (EQ cmp yes no) (NE (InvertFlags cmp) yes no) => (NE cmp yes no) // Constant comparisons. (CMPQconst (MOVQconst [x]) [y]) && x==int64(y) => (FlagEQ) (CMPQconst (MOVQconst [x]) [y]) && x<int64(y) && uint64(x)<uint64(int64(y)) => (FlagLT_ULT) (CMPQconst (MOVQconst [x]) [y]) && x<int64(y) && uint64(x)>uint64(int64(y)) => (FlagLT_UGT) (CMPQconst (MOVQconst [x]) [y]) && x>int64(y) && uint64(x)<uint64(int64(y)) => (FlagGT_ULT) (CMPQconst (MOVQconst [x]) [y]) && x>int64(y) && uint64(x)>uint64(int64(y)) => (FlagGT_UGT) (CMPLconst (MOVLconst [x]) [y]) && x==y => (FlagEQ) (CMPLconst (MOVLconst [x]) [y]) && x<y && uint32(x)<uint32(y) => (FlagLT_ULT) (CMPLconst (MOVLconst [x]) [y]) && x<y && uint32(x)>uint32(y) => (FlagLT_UGT) (CMPLconst (MOVLconst [x]) [y]) && x>y && uint32(x)<uint32(y) => (FlagGT_ULT) (CMPLconst (MOVLconst [x]) [y]) && x>y && uint32(x)>uint32(y) => (FlagGT_UGT) (CMPWconst (MOVLconst [x]) [y]) && int16(x)==y => (FlagEQ) (CMPWconst (MOVLconst [x]) [y]) && int16(x)<y && uint16(x)<uint16(y) => (FlagLT_ULT) (CMPWconst (MOVLconst [x]) [y]) && int16(x)<y && uint16(x)>uint16(y) => (FlagLT_UGT) (CMPWconst (MOVLconst [x]) [y]) && int16(x)>y && uint16(x)<uint16(y) => (FlagGT_ULT) (CMPWconst (MOVLconst [x]) [y]) && int16(x)>y && uint16(x)>uint16(y) => (FlagGT_UGT) (CMPBconst (MOVLconst [x]) [y]) && int8(x)==y => (FlagEQ) (CMPBconst (MOVLconst [x]) [y]) && int8(x)<y && uint8(x)<uint8(y) => (FlagLT_ULT) (CMPBconst (MOVLconst [x]) [y]) && int8(x)<y && uint8(x)>uint8(y) => (FlagLT_UGT) (CMPBconst (MOVLconst [x]) [y]) && int8(x)>y && uint8(x)<uint8(y) => (FlagGT_ULT) (CMPBconst (MOVLconst [x]) [y]) && int8(x)>y && uint8(x)>uint8(y) => (FlagGT_UGT) // CMPQconst requires a 32 bit const, but we can still constant-fold 64 bit consts. // In theory this applies to any of the simplifications above, // but CMPQ is the only one I've actually seen occur. (CMPQ (MOVQconst [x]) (MOVQconst [y])) && x==y => (FlagEQ) (CMPQ (MOVQconst [x]) (MOVQconst [y])) && x<y && uint64(x)<uint64(y) => (FlagLT_ULT) (CMPQ (MOVQconst [x]) (MOVQconst [y])) && x<y && uint64(x)>uint64(y) => (FlagLT_UGT) (CMPQ (MOVQconst [x]) (MOVQconst [y])) && x>y && uint64(x)<uint64(y) => (FlagGT_ULT) (CMPQ (MOVQconst [x]) (MOVQconst [y])) && x>y && uint64(x)>uint64(y) => (FlagGT_UGT) // Other known comparisons. (CMPQconst (MOVBQZX _) [c]) && 0xFF < c => (FlagLT_ULT) (CMPQconst (MOVWQZX _) [c]) && 0xFFFF < c => (FlagLT_ULT) (CMPLconst (SHRLconst _ [c]) [n]) && 0 <= n && 0 < c && c <= 32 && (1<<uint64(32-c)) <= uint64(n) => (FlagLT_ULT) (CMPQconst (SHRQconst _ [c]) [n]) && 0 <= n && 0 < c && c <= 64 && (1<<uint64(64-c)) <= uint64(n) => (FlagLT_ULT) (CMPQconst (ANDQconst _ [m]) [n]) && 0 <= m && m < n => (FlagLT_ULT) (CMPQconst (ANDLconst _ [m]) [n]) && 0 <= m && m < n => (FlagLT_ULT) (CMPLconst (ANDLconst _ [m]) [n]) && 0 <= m && m < n => (FlagLT_ULT) (CMPWconst (ANDLconst _ [m]) [n]) && 0 <= int16(m) && int16(m) < n => (FlagLT_ULT) (CMPBconst (ANDLconst _ [m]) [n]) && 0 <= int8(m) && int8(m) < n => (FlagLT_ULT) // TESTQ c c sets flags like CMPQ c 0. (TESTQconst [c] (MOVQconst [d])) && int64(c) == d && c == 0 => (FlagEQ) (TESTLconst [c] (MOVLconst [c])) && c == 0 => (FlagEQ) (TESTQconst [c] (MOVQconst [d])) && int64(c) == d && c < 0 => (FlagLT_UGT) (TESTLconst [c] (MOVLconst [c])) && c < 0 => (FlagLT_UGT) (TESTQconst [c] (MOVQconst [d])) && int64(c) == d && c > 0 => (FlagGT_UGT) (TESTLconst [c] (MOVLconst [c])) && c > 0 => (FlagGT_UGT) // TODO: DIVxU also. // Absorb flag constants into SBB ops. (SBBQcarrymask (FlagEQ)) => (MOVQconst [0]) (SBBQcarrymask (FlagLT_ULT)) => (MOVQconst [-1]) (SBBQcarrymask (FlagLT_UGT)) => (MOVQconst [0]) (SBBQcarrymask (FlagGT_ULT)) => (MOVQconst [-1]) (SBBQcarrymask (FlagGT_UGT)) => (MOVQconst [0]) (SBBLcarrymask (FlagEQ)) => (MOVLconst [0]) (SBBLcarrymask (FlagLT_ULT)) => (MOVLconst [-1]) (SBBLcarrymask (FlagLT_UGT)) => (MOVLconst [0]) (SBBLcarrymask (FlagGT_ULT)) => (MOVLconst [-1]) (SBBLcarrymask (FlagGT_UGT)) => (MOVLconst [0]) // Absorb flag constants into branches. ((EQ|LE|GE|ULE|UGE) (FlagEQ) yes no) => (First yes no) ((NE|LT|GT|ULT|UGT) (FlagEQ) yes no) => (First no yes) ((NE|LT|LE|ULT|ULE) (FlagLT_ULT) yes no) => (First yes no) ((EQ|GT|GE|UGT|UGE) (FlagLT_ULT) yes no) => (First no yes) ((NE|LT|LE|UGT|UGE) (FlagLT_UGT) yes no) => (First yes no) ((EQ|GT|GE|ULT|ULE) (FlagLT_UGT) yes no) => (First no yes) ((NE|GT|GE|ULT|ULE) (FlagGT_ULT) yes no) => (First yes no) ((EQ|LT|LE|UGT|UGE) (FlagGT_ULT) yes no) => (First no yes) ((NE|GT|GE|UGT|UGE) (FlagGT_UGT) yes no) => (First yes no) ((EQ|LT|LE|ULT|ULE) (FlagGT_UGT) yes no) => (First no yes) // Absorb flag constants into SETxx ops. ((SETEQ|SETLE|SETGE|SETBE|SETAE) (FlagEQ)) => (MOVLconst [1]) ((SETNE|SETL|SETG|SETB|SETA) (FlagEQ)) => (MOVLconst [0]) ((SETNE|SETL|SETLE|SETB|SETBE) (FlagLT_ULT)) => (MOVLconst [1]) ((SETEQ|SETG|SETGE|SETA|SETAE) (FlagLT_ULT)) => (MOVLconst [0]) ((SETNE|SETL|SETLE|SETA|SETAE) (FlagLT_UGT)) => (MOVLconst [1]) ((SETEQ|SETG|SETGE|SETB|SETBE) (FlagLT_UGT)) => (MOVLconst [0]) ((SETNE|SETG|SETGE|SETB|SETBE) (FlagGT_ULT)) => (MOVLconst [1]) ((SETEQ|SETL|SETLE|SETA|SETAE) (FlagGT_ULT)) => (MOVLconst [0]) ((SETNE|SETG|SETGE|SETA|SETAE) (FlagGT_UGT)) => (MOVLconst [1]) ((SETEQ|SETL|SETLE|SETB|SETBE) (FlagGT_UGT)) => (MOVLconst [0]) (SETEQstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETEQstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETEQstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETEQstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETEQstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETNEstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETNEstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETNEstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETNEstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETNEstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETLstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETLstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETLstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETLstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETLstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETLEstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETLEstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETLEstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETLEstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETLEstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETGstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETGstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETGstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETGstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETGstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETGEstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETGEstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETGEstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETGEstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETGEstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETBstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETBstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETBstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETBstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETBstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETBEstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETBEstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETBEstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETBEstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETBEstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETAstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETAstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETAstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETAstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETAstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETAEstore [off] {sym} ptr (FlagEQ) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETAEstore [off] {sym} ptr (FlagLT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETAEstore [off] {sym} ptr (FlagLT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) (SETAEstore [off] {sym} ptr (FlagGT_ULT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [0]) mem) (SETAEstore [off] {sym} ptr (FlagGT_UGT) mem) => (MOVBstore [off] {sym} ptr (MOVLconst <typ.UInt8> [1]) mem) // Remove redundant *const ops (ADDQconst [0] x) => x (ADDLconst [c] x) && c==0 => x (SUBQconst [0] x) => x (SUBLconst [c] x) && c==0 => x (ANDQconst [0] _) => (MOVQconst [0]) (ANDLconst [c] _) && c==0 => (MOVLconst [0]) (ANDQconst [-1] x) => x (ANDLconst [c] x) && c==-1 => x (ORQconst [0] x) => x (ORLconst [c] x) && c==0 => x (ORQconst [-1] _) => (MOVQconst [-1]) (ORLconst [c] _) && c==-1 => (MOVLconst [-1]) (XORQconst [0] x) => x (XORLconst [c] x) && c==0 => x // TODO: since we got rid of the W/B versions, we might miss // things like (ANDLconst [0x100] x) which were formerly // (ANDBconst [0] x). Probably doesn't happen very often. // If we cared, we might do: // (ANDLconst <t> [c] x) && t.Size()==1 && int8(x)==0 -> (MOVLconst [0]) // Remove redundant ops // Not in generic rules, because they may appear after lowering e. g. Slicemask (NEG(Q|L) (NEG(Q|L) x)) => x (NEG(Q|L) s:(SUB(Q|L) x y)) && s.Uses == 1 => (SUB(Q|L) y x) // Convert constant subtracts to constant adds (SUBQconst [c] x) && c != -(1<<31) => (ADDQconst [-c] x) (SUBLconst [c] x) => (ADDLconst [-c] x) // generic constant folding // TODO: more of this (ADDQconst [c] (MOVQconst [d])) => (MOVQconst [int64(c)+d]) (ADDLconst [c] (MOVLconst [d])) => (MOVLconst [c+d]) (ADDQconst [c] (ADDQconst [d] x)) && is32Bit(int64(c)+int64(d)) => (ADDQconst [c+d] x) (ADDLconst [c] (ADDLconst [d] x)) => (ADDLconst [c+d] x) (SUBQconst (MOVQconst [d]) [c]) => (MOVQconst [d-int64(c)]) (SUBQconst (SUBQconst x [d]) [c]) && is32Bit(int64(-c)-int64(d)) => (ADDQconst [-c-d] x) (SARQconst [c] (MOVQconst [d])) => (MOVQconst [d>>uint64(c)]) (SARLconst [c] (MOVQconst [d])) => (MOVQconst [int64(int32(d))>>uint64(c)]) (SARWconst [c] (MOVQconst [d])) => (MOVQconst [int64(int16(d))>>uint64(c)]) (SARBconst [c] (MOVQconst [d])) => (MOVQconst [int64(int8(d))>>uint64(c)]) (NEGQ (MOVQconst [c])) => (MOVQconst [-c]) (NEGL (MOVLconst [c])) => (MOVLconst [-c]) (MULQconst [c] (MOVQconst [d])) => (MOVQconst [int64(c)*d]) (MULLconst [c] (MOVLconst [d])) => (MOVLconst [c*d]) (ANDQconst [c] (MOVQconst [d])) => (MOVQconst [int64(c)&d]) (ANDLconst [c] (MOVLconst [d])) => (MOVLconst [c&d]) (ORQconst [c] (MOVQconst [d])) => (MOVQconst [int64(c)|d]) (ORLconst [c] (MOVLconst [d])) => (MOVLconst [c|d]) (XORQconst [c] (MOVQconst [d])) => (MOVQconst [int64(c)^d]) (XORLconst [c] (MOVLconst [d])) => (MOVLconst [c^d]) (NOTQ (MOVQconst [c])) => (MOVQconst [^c]) (NOTL (MOVLconst [c])) => (MOVLconst [^c]) (BTSQconst [c] (MOVQconst [d])) => (MOVQconst [d|(1<<uint32(c))]) (BTRQconst [c] (MOVQconst [d])) => (MOVQconst [d&^(1<<uint32(c))]) (BTCQconst [c] (MOVQconst [d])) => (MOVQconst [d^(1<<uint32(c))]) // If c or d doesn't fit into 32 bits, then we can't construct ORQconst, // but we can still constant-fold. // In theory this applies to any of the simplifications above, // but ORQ is the only one I've actually seen occur. (ORQ (MOVQconst [c]) (MOVQconst [d])) => (MOVQconst [c|d]) // generic simplifications // TODO: more of this (ADDQ x (NEGQ y)) => (SUBQ x y) (ADDL x (NEGL y)) => (SUBL x y) (SUBQ x x) => (MOVQconst [0]) (SUBL x x) => (MOVLconst [0]) (ANDQ x x) => x (ANDL x x) => x (ORQ x x) => x (ORL x x) => x (XORQ x x) => (MOVQconst [0]) (XORL x x) => (MOVLconst [0]) (SHLLconst [d] (MOVLconst [c])) => (MOVLconst [c << uint64(d)]) (SHLQconst [d] (MOVQconst [c])) => (MOVQconst [c << uint64(d)]) (SHLQconst [d] (MOVLconst [c])) => (MOVQconst [int64(c) << uint64(d)]) // Fold NEG into ADDconst/MULconst. Take care to keep c in 32 bit range. (NEGQ (ADDQconst [c] (NEGQ x))) && c != -(1<<31) => (ADDQconst [-c] x) (MULQconst [c] (NEGQ x)) && c != -(1<<31) => (MULQconst [-c] x) // checking AND against 0. (CMPQconst a:(ANDQ x y) [0]) && a.Uses == 1 => (TESTQ x y) (CMPLconst a:(ANDL x y) [0]) && a.Uses == 1 => (TESTL x y) (CMPWconst a:(ANDL x y) [0]) && a.Uses == 1 => (TESTW x y) (CMPBconst a:(ANDL x y) [0]) && a.Uses == 1 => (TESTB x y) (CMPQconst a:(ANDQconst [c] x) [0]) && a.Uses == 1 => (TESTQconst [c] x) (CMPLconst a:(ANDLconst [c] x) [0]) && a.Uses == 1 => (TESTLconst [c] x) (CMPWconst a:(ANDLconst [c] x) [0]) && a.Uses == 1 => (TESTWconst [int16(c)] x) (CMPBconst a:(ANDLconst [c] x) [0]) && a.Uses == 1 => (TESTBconst [int8(c)] x) // Convert TESTx to TESTxconst if possible. (TESTQ (MOVQconst [c]) x) && is32Bit(c) => (TESTQconst [int32(c)] x) (TESTL (MOVLconst [c]) x) => (TESTLconst [c] x) (TESTW (MOVLconst [c]) x) => (TESTWconst [int16(c)] x) (TESTB (MOVLconst [c]) x) => (TESTBconst [int8(c)] x) // TEST %reg,%reg is shorter than CMP (CMPQconst x [0]) => (TESTQ x x) (CMPLconst x [0]) => (TESTL x x) (CMPWconst x [0]) => (TESTW x x) (CMPBconst x [0]) => (TESTB x x) (TESTQconst [-1] x) && x.Op != OpAMD64MOVQconst => (TESTQ x x) (TESTLconst [-1] x) && x.Op != OpAMD64MOVLconst => (TESTL x x) (TESTWconst [-1] x) && x.Op != OpAMD64MOVLconst => (TESTW x x) (TESTBconst [-1] x) && x.Op != OpAMD64MOVLconst => (TESTB x x) // Convert LEAQ1 back to ADDQ if we can (LEAQ1 [0] x y) && v.Aux == nil => (ADDQ x y) (MOVQstoreconst [c] {s} p1 x:(MOVQstoreconst [a] {s} p0 mem)) && config.useSSE && x.Uses == 1 && sequentialAddresses(p0, p1, int64(a.Off()+8-c.Off())) && a.Val() == 0 && c.Val() == 0 && setPos(v, x.Pos) && clobber(x) => (MOVOstoreconst [makeValAndOff(0,a.Off())] {s} p0 mem) (MOVQstoreconst [a] {s} p0 x:(MOVQstoreconst [c] {s} p1 mem)) && config.useSSE && x.Uses == 1 && sequentialAddresses(p0, p1, int64(a.Off()+8-c.Off())) && a.Val() == 0 && c.Val() == 0 && setPos(v, x.Pos) && clobber(x) => (MOVOstoreconst [makeValAndOff(0,a.Off())] {s} p0 mem) // Merge load and op // TODO: add indexed variants? ((ADD|SUB|AND|OR|XOR)Q x l:(MOVQload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && clobber(l) => ((ADD|SUB|AND|OR|XOR)Qload x [off] {sym} ptr mem) ((ADD|SUB|AND|OR|XOR)L x l:(MOVLload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && clobber(l) => ((ADD|SUB|AND|OR|XOR)Lload x [off] {sym} ptr mem) ((ADD|SUB|MUL|DIV)SD x l:(MOVSDload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && clobber(l) => ((ADD|SUB|MUL|DIV)SDload x [off] {sym} ptr mem) ((ADD|SUB|MUL|DIV)SS x l:(MOVSSload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && clobber(l) => ((ADD|SUB|MUL|DIV)SSload x [off] {sym} ptr mem) (MOVLstore {sym} [off] ptr y:((ADD|AND|OR|XOR)Lload x [off] {sym} ptr mem) mem) && y.Uses==1 && clobber(y) => ((ADD|AND|OR|XOR)Lmodify [off] {sym} ptr x mem) (MOVLstore {sym} [off] ptr y:((ADD|SUB|AND|OR|XOR)L l:(MOVLload [off] {sym} ptr mem) x) mem) && y.Uses==1 && l.Uses==1 && clobber(y, l) => ((ADD|SUB|AND|OR|XOR)Lmodify [off] {sym} ptr x mem) (MOVQstore {sym} [off] ptr y:((ADD|AND|OR|XOR)Qload x [off] {sym} ptr mem) mem) && y.Uses==1 && clobber(y) => ((ADD|AND|OR|XOR)Qmodify [off] {sym} ptr x mem) (MOVQstore {sym} [off] ptr y:((ADD|SUB|AND|OR|XOR)Q l:(MOVQload [off] {sym} ptr mem) x) mem) && y.Uses==1 && l.Uses==1 && clobber(y, l) => ((ADD|SUB|AND|OR|XOR)Qmodify [off] {sym} ptr x mem) (MOVQstore {sym} [off] ptr x:(BT(S|R|C)Qconst [c] l:(MOVQload {sym} [off] ptr mem)) mem) && x.Uses == 1 && l.Uses == 1 && clobber(x, l) => (BT(S|R|C)Qconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) // Merge ADDQconst and LEAQ into atomic loads. (MOV(Q|L|B)atomicload [off1] {sym} (ADDQconst [off2] ptr) mem) && is32Bit(int64(off1)+int64(off2)) => (MOV(Q|L|B)atomicload [off1+off2] {sym} ptr mem) (MOV(Q|L|B)atomicload [off1] {sym1} (LEAQ [off2] {sym2} ptr) mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) => (MOV(Q|L|B)atomicload [off1+off2] {mergeSym(sym1, sym2)} ptr mem) // Merge ADDQconst and LEAQ into atomic stores. (XCHGQ [off1] {sym} val (ADDQconst [off2] ptr) mem) && is32Bit(int64(off1)+int64(off2)) => (XCHGQ [off1+off2] {sym} val ptr mem) (XCHGQ [off1] {sym1} val (LEAQ [off2] {sym2} ptr) mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && ptr.Op != OpSB => (XCHGQ [off1+off2] {mergeSym(sym1,sym2)} val ptr mem) (XCHGL [off1] {sym} val (ADDQconst [off2] ptr) mem) && is32Bit(int64(off1)+int64(off2)) => (XCHGL [off1+off2] {sym} val ptr mem) (XCHGL [off1] {sym1} val (LEAQ [off2] {sym2} ptr) mem) && is32Bit(int64(off1)+int64(off2)) && canMergeSym(sym1, sym2) && ptr.Op != OpSB => (XCHGL [off1+off2] {mergeSym(sym1,sym2)} val ptr mem) // Merge ADDQconst into atomic adds. // TODO: merging LEAQ doesn't work, assembler doesn't like the resulting instructions. (XADDQlock [off1] {sym} val (ADDQconst [off2] ptr) mem) && is32Bit(int64(off1)+int64(off2)) => (XADDQlock [off1+off2] {sym} val ptr mem) (XADDLlock [off1] {sym} val (ADDQconst [off2] ptr) mem) && is32Bit(int64(off1)+int64(off2)) => (XADDLlock [off1+off2] {sym} val ptr mem) // Merge ADDQconst into atomic compare and swaps. // TODO: merging LEAQ doesn't work, assembler doesn't like the resulting instructions. (CMPXCHGQlock [off1] {sym} (ADDQconst [off2] ptr) old new_ mem) && is32Bit(int64(off1)+int64(off2)) => (CMPXCHGQlock [off1+off2] {sym} ptr old new_ mem) (CMPXCHGLlock [off1] {sym} (ADDQconst [off2] ptr) old new_ mem) && is32Bit(int64(off1)+int64(off2)) => (CMPXCHGLlock [off1+off2] {sym} ptr old new_ mem) // We don't need the conditional move if we know the arg of BSF is not zero. (CMOVQEQ x _ (Select1 (BS(F|R)Q (ORQconst [c] _)))) && c != 0 => x // Extension is unnecessary for trailing zeros. (BSFQ (ORQconst <t> [1<<8] (MOVBQZX x))) => (BSFQ (ORQconst <t> [1<<8] x)) (BSFQ (ORQconst <t> [1<<16] (MOVWQZX x))) => (BSFQ (ORQconst <t> [1<<16] x)) // Redundant sign/zero extensions // Note: see issue 21963. We have to make sure we use the right type on // the resulting extension (the outer type, not the inner type). (MOVLQSX (MOVLQSX x)) => (MOVLQSX x) (MOVLQSX (MOVWQSX x)) => (MOVWQSX x) (MOVLQSX (MOVBQSX x)) => (MOVBQSX x) (MOVWQSX (MOVWQSX x)) => (MOVWQSX x) (MOVWQSX (MOVBQSX x)) => (MOVBQSX x) (MOVBQSX (MOVBQSX x)) => (MOVBQSX x) (MOVLQZX (MOVLQZX x)) => (MOVLQZX x) (MOVLQZX (MOVWQZX x)) => (MOVWQZX x) (MOVLQZX (MOVBQZX x)) => (MOVBQZX x) (MOVWQZX (MOVWQZX x)) => (MOVWQZX x) (MOVWQZX (MOVBQZX x)) => (MOVBQZX x) (MOVBQZX (MOVBQZX x)) => (MOVBQZX x) (MOVQstore [off] {sym} ptr a:((ADD|AND|OR|XOR)Qconst [c] l:(MOVQload [off] {sym} ptr2 mem)) mem) && isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) => ((ADD|AND|OR|XOR)Qconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) (MOVLstore [off] {sym} ptr a:((ADD|AND|OR|XOR)Lconst [c] l:(MOVLload [off] {sym} ptr2 mem)) mem) && isSamePtr(ptr, ptr2) && a.Uses == 1 && l.Uses == 1 && clobber(l, a) => ((ADD|AND|OR|XOR)Lconstmodify {sym} [makeValAndOff(int32(c),off)] ptr mem) // float <-> int register moves, with no conversion. // These come up when compiling math.{Float{32,64}bits,Float{32,64}frombits}. (MOVQload [off] {sym} ptr (MOVSDstore [off] {sym} ptr val _)) => (MOVQf2i val) (MOVLload [off] {sym} ptr (MOVSSstore [off] {sym} ptr val _)) => (MOVLf2i val) (MOVSDload [off] {sym} ptr (MOVQstore [off] {sym} ptr val _)) => (MOVQi2f val) (MOVSSload [off] {sym} ptr (MOVLstore [off] {sym} ptr val _)) => (MOVLi2f val) // Other load-like ops. (ADDQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) => (ADDQ x (MOVQf2i y)) (ADDLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) => (ADDL x (MOVLf2i y)) (SUBQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) => (SUBQ x (MOVQf2i y)) (SUBLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) => (SUBL x (MOVLf2i y)) (ANDQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) => (ANDQ x (MOVQf2i y)) (ANDLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) => (ANDL x (MOVLf2i y)) ( ORQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) => ( ORQ x (MOVQf2i y)) ( ORLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) => ( ORL x (MOVLf2i y)) (XORQload x [off] {sym} ptr (MOVSDstore [off] {sym} ptr y _)) => (XORQ x (MOVQf2i y)) (XORLload x [off] {sym} ptr (MOVSSstore [off] {sym} ptr y _)) => (XORL x (MOVLf2i y)) (ADDSDload x [off] {sym} ptr (MOVQstore [off] {sym} ptr y _)) => (ADDSD x (MOVQi2f y)) (ADDSSload x [off] {sym} ptr (MOVLstore [off] {sym} ptr y _)) => (ADDSS x (MOVLi2f y)) (SUBSDload x [off] {sym} ptr (MOVQstore [off] {sym} ptr y _)) => (SUBSD x (MOVQi2f y)) (SUBSSload x [off] {sym} ptr (MOVLstore [off] {sym} ptr y _)) => (SUBSS x (MOVLi2f y)) (MULSDload x [off] {sym} ptr (MOVQstore [off] {sym} ptr y _)) => (MULSD x (MOVQi2f y)) (MULSSload x [off] {sym} ptr (MOVLstore [off] {sym} ptr y _)) => (MULSS x (MOVLi2f y)) // Redirect stores to use the other register set. (MOVQstore [off] {sym} ptr (MOVQf2i val) mem) => (MOVSDstore [off] {sym} ptr val mem) (MOVLstore [off] {sym} ptr (MOVLf2i val) mem) => (MOVSSstore [off] {sym} ptr val mem) (MOVSDstore [off] {sym} ptr (MOVQi2f val) mem) => (MOVQstore [off] {sym} ptr val mem) (MOVSSstore [off] {sym} ptr (MOVLi2f val) mem) => (MOVLstore [off] {sym} ptr val mem) (MOVSDstore [off] {sym} ptr (MOVSDconst [f]) mem) && f == f => (MOVQstore [off] {sym} ptr (MOVQconst [int64(math.Float64bits(f))]) mem) (MOVSSstore [off] {sym} ptr (MOVSSconst [f]) mem) && f == f => (MOVLstore [off] {sym} ptr (MOVLconst [int32(math.Float32bits(f))]) mem) // Load args directly into the register class where it will be used. // We do this by just modifying the type of the Arg. (MOVQf2i <t> (Arg <u> [off] {sym})) && t.Size() == u.Size() => @b.Func.Entry (Arg <t> [off] {sym}) (MOVLf2i <t> (Arg <u> [off] {sym})) && t.Size() == u.Size() => @b.Func.Entry (Arg <t> [off] {sym}) (MOVQi2f <t> (Arg <u> [off] {sym})) && t.Size() == u.Size() => @b.Func.Entry (Arg <t> [off] {sym}) (MOVLi2f <t> (Arg <u> [off] {sym})) && t.Size() == u.Size() => @b.Func.Entry (Arg <t> [off] {sym}) // LEAQ is rematerializeable, so this helps to avoid register spill. // See issue 22947 for details (ADD(Q|L)const [off] x:(SP)) => (LEA(Q|L) [off] x) // HMULx is commutative, but its first argument must go in AX. // If possible, put a rematerializeable value in the first argument slot, // to reduce the odds that another value will be have to spilled // specifically to free up AX. (HMUL(Q|L) x y) && !x.rematerializeable() && y.rematerializeable() => (HMUL(Q|L) y x) (HMUL(Q|L)U x y) && !x.rematerializeable() && y.rematerializeable() => (HMUL(Q|L)U y x) // Fold loads into compares // Note: these may be undone by the flagalloc pass. (CMP(Q|L|W|B) l:(MOV(Q|L|W|B)load {sym} [off] ptr mem) x) && canMergeLoad(v, l) && clobber(l) => (CMP(Q|L|W|B)load {sym} [off] ptr x mem) (CMP(Q|L|W|B) x l:(MOV(Q|L|W|B)load {sym} [off] ptr mem)) && canMergeLoad(v, l) && clobber(l) => (InvertFlags (CMP(Q|L|W|B)load {sym} [off] ptr x mem)) (CMP(Q|L)const l:(MOV(Q|L)load {sym} [off] ptr mem) [c]) && l.Uses == 1 && clobber(l) => @l.Block (CMP(Q|L)constload {sym} [makeValAndOff(c,off)] ptr mem) (CMP(W|B)const l:(MOV(W|B)load {sym} [off] ptr mem) [c]) && l.Uses == 1 && clobber(l) => @l.Block (CMP(W|B)constload {sym} [makeValAndOff(int32(c),off)] ptr mem) (CMPQload {sym} [off] ptr (MOVQconst [c]) mem) && validVal(c) => (CMPQconstload {sym} [makeValAndOff(int32(c),off)] ptr mem) (CMPLload {sym} [off] ptr (MOVLconst [c]) mem) => (CMPLconstload {sym} [makeValAndOff(c,off)] ptr mem) (CMPWload {sym} [off] ptr (MOVLconst [c]) mem) => (CMPWconstload {sym} [makeValAndOff(int32(int16(c)),off)] ptr mem) (CMPBload {sym} [off] ptr (MOVLconst [c]) mem) => (CMPBconstload {sym} [makeValAndOff(int32(int8(c)),off)] ptr mem) (TEST(Q|L|W|B) l:(MOV(Q|L|W|B)load {sym} [off] ptr mem) l2) && l == l2 && l.Uses == 2 && clobber(l) => @l.Block (CMP(Q|L|W|B)constload {sym} [makeValAndOff(0, off)] ptr mem) // Convert ANDload to MOVload when we can do the AND in a containing TEST op. // Only do when it's within the same block, so we don't have flags live across basic block boundaries. // See issue 44228. (TEST(Q|L) a:(AND(Q|L)load [off] {sym} x ptr mem) a) && a.Uses == 2 && a.Block == v.Block && clobber(a) => (TEST(Q|L) (MOV(Q|L)load <a.Type> [off] {sym} ptr mem) x) (MOVBload [off] {sym} (SB) _) && symIsRO(sym) => (MOVLconst [int32(read8(sym, int64(off)))]) (MOVWload [off] {sym} (SB) _) && symIsRO(sym) => (MOVLconst [int32(read16(sym, int64(off), config.ctxt.Arch.ByteOrder))]) (MOVLload [off] {sym} (SB) _) && symIsRO(sym) => (MOVQconst [int64(read32(sym, int64(off), config.ctxt.Arch.ByteOrder))]) (MOVQload [off] {sym} (SB) _) && symIsRO(sym) => (MOVQconst [int64(read64(sym, int64(off), config.ctxt.Arch.ByteOrder))]) (MOVOstore [dstOff] {dstSym} ptr (MOVOload [srcOff] {srcSym} (SB) _) mem) && symIsRO(srcSym) => (MOVQstore [dstOff+8] {dstSym} ptr (MOVQconst [int64(read64(srcSym, int64(srcOff)+8, config.ctxt.Arch.ByteOrder))]) (MOVQstore [dstOff] {dstSym} ptr (MOVQconst [int64(read64(srcSym, int64(srcOff), config.ctxt.Arch.ByteOrder))]) mem)) // Arch-specific inlining for small or disjoint runtime.memmove // Match post-lowering calls, memory version. (SelectN [0] call:(CALLstatic {sym} s1:(MOVQstoreconst _ [sc] s2:(MOVQstore _ src s3:(MOVQstore _ dst mem))))) && sc.Val64() >= 0 && isSameCall(sym, "runtime.memmove") && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, sc.Val64(), config) && clobber(s1, s2, s3, call) => (Move [sc.Val64()] dst src mem) // Match post-lowering calls, register version. (SelectN [0] call:(CALLstatic {sym} dst src (MOVQconst [sz]) mem)) && sz >= 0 && isSameCall(sym, "runtime.memmove") && call.Uses == 1 && isInlinableMemmove(dst, src, sz, config) && clobber(call) => (Move [sz] dst src mem) // Prefetch instructions (PrefetchCache ...) => (PrefetchT0 ...) (PrefetchCacheStreamed ...) => (PrefetchNTA ...) // CPUID feature: BMI1. (AND(Q|L) x (NOT(Q|L) y)) && buildcfg.GOAMD64 >= 3 => (ANDN(Q|L) x y) (AND(Q|L) x (NEG(Q|L) x)) && buildcfg.GOAMD64 >= 3 => (BLSI(Q|L) x) (XOR(Q|L) x (ADD(Q|L)const [-1] x)) && buildcfg.GOAMD64 >= 3 => (BLSMSK(Q|L) x) (AND(Q|L) <t> x (ADD(Q|L)const [-1] x)) && buildcfg.GOAMD64 >= 3 => (Select0 <t> (BLSR(Q|L) x)) // eliminate TEST instruction in classical "isPowerOfTwo" check (SETEQ (TEST(Q|L) s:(Select0 blsr:(BLSR(Q|L) _)) s)) => (SETEQ (Select1 <types.TypeFlags> blsr)) (CMOVQEQ x y (TEST(Q|L) s:(Select0 blsr:(BLSR(Q|L) _)) s)) => (CMOVQEQ x y (Select1 <types.TypeFlags> blsr)) (CMOVLEQ x y (TEST(Q|L) s:(Select0 blsr:(BLSR(Q|L) _)) s)) => (CMOVLEQ x y (Select1 <types.TypeFlags> blsr)) (EQ (TEST(Q|L) s:(Select0 blsr:(BLSR(Q|L) _)) s) yes no) => (EQ (Select1 <types.TypeFlags> blsr) yes no) (SETNE (TEST(Q|L) s:(Select0 blsr:(BLSR(Q|L) _)) s)) => (SETNE (Select1 <types.TypeFlags> blsr)) (CMOVQNE x y (TEST(Q|L) s:(Select0 blsr:(BLSR(Q|L) _)) s)) => (CMOVQNE x y (Select1 <types.TypeFlags> blsr)) (CMOVLNE x y (TEST(Q|L) s:(Select0 blsr:(BLSR(Q|L) _)) s)) => (CMOVLNE x y (Select1 <types.TypeFlags> blsr)) (NE (TEST(Q|L) s:(Select0 blsr:(BLSR(Q|L) _)) s) yes no) => (NE (Select1 <types.TypeFlags> blsr) yes no) (BSWAP(Q|L) (BSWAP(Q|L) p)) => p // CPUID feature: MOVBE. (MOV(Q|L)store [i] {s} p x:(BSWAP(Q|L) w) mem) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => (MOVBE(Q|L)store [i] {s} p w mem) (MOVBE(Q|L)store [i] {s} p x:(BSWAP(Q|L) w) mem) && x.Uses == 1 => (MOV(Q|L)store [i] {s} p w mem) (BSWAP(Q|L) x:(MOV(Q|L)load [i] {s} p mem)) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => @x.Block (MOVBE(Q|L)load [i] {s} p mem) (BSWAP(Q|L) x:(MOVBE(Q|L)load [i] {s} p mem)) && x.Uses == 1 => @x.Block (MOV(Q|L)load [i] {s} p mem) (MOVWstore [i] {s} p x:(ROLWconst [8] w) mem) && x.Uses == 1 && buildcfg.GOAMD64 >= 3 => (MOVBEWstore [i] {s} p w mem) (MOVBEWstore [i] {s} p x:(ROLWconst [8] w) mem) && x.Uses == 1 => (MOVWstore [i] {s} p w mem) (SAR(Q|L) l:(MOV(Q|L)load [off] {sym} ptr mem) x) && buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) => (SARX(Q|L)load [off] {sym} ptr x mem) (SHL(Q|L) l:(MOV(Q|L)load [off] {sym} ptr mem) x) && buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) => (SHLX(Q|L)load [off] {sym} ptr x mem) (SHR(Q|L) l:(MOV(Q|L)load [off] {sym} ptr mem) x) && buildcfg.GOAMD64 >= 3 && canMergeLoad(v, l) && clobber(l) => (SHRX(Q|L)load [off] {sym} ptr x mem) ((SHL|SHR|SAR)XQload [off] {sym} ptr (MOVQconst [c]) mem) => ((SHL|SHR|SAR)Qconst [int8(c&63)] (MOVQload [off] {sym} ptr mem)) ((SHL|SHR|SAR)XQload [off] {sym} ptr (MOVLconst [c]) mem) => ((SHL|SHR|SAR)Qconst [int8(c&63)] (MOVQload [off] {sym} ptr mem)) ((SHL|SHR|SAR)XLload [off] {sym} ptr (MOVLconst [c]) mem) => ((SHL|SHR|SAR)Lconst [int8(c&31)] (MOVLload [off] {sym} ptr mem)) // Convert atomic logical operations to easier ones if we don't use the result. (Select1 a:(LoweredAtomic(And64|And32|Or64|Or32) ptr val mem)) && a.Uses == 1 && clobber(a) => ((ANDQ|ANDL|ORQ|ORL)lock ptr val mem)
go/src/cmd/compile/internal/ssa/_gen/AMD64.rules/0
{ "file_path": "go/src/cmd/compile/internal/ssa/_gen/AMD64.rules", "repo_id": "go", "token_count": 46999 }
99