repo_name
stringlengths
4
116
path
stringlengths
3
942
size
stringlengths
1
7
content
stringlengths
3
1.05M
license
stringclasses
15 values
dnolivieri/rfMHC
docs/conf.py
8369
#!/usr/bin/env python # -*- coding: utf-8 -*- # # rfMHC documentation build configuration file, created by # sphinx-quickstart on Tue Jul 9 22:26:36 2013. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys import os # If extensions (or modules to document with autodoc) are in another # directory, add these directories to sys.path here. If the directory is # relative to the documentation root, use os.path.abspath to make it # absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # Get the project root dir, which is the parent dir of this cwd = os.getcwd() project_root = os.path.dirname(cwd) # Insert the project root dir as the first element in the PYTHONPATH. # This lets us ensure that the source package is imported, and that its # version is used. sys.path.insert(0, project_root) import rfMHC # -- General configuration --------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8-sig' # The master toctree document. master_doc = 'index' # General information about the project. project = u'rfMHC' copyright = u'2014, David Olivieri' # The version info for the project you're documenting, acts as replacement # for |version| and |release|, also used in various other places throughout # the built documents. # # The short X.Y version. version = rfMHC.__version__ # The full version, including alpha/beta/rc tags. release = rfMHC.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to # some non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = ['_build'] # The reST default role (used for this markup: `text`) to use for all # documents. #default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. #add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). #add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. #show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = 'sphinx' # A list of ignored prefixes for module index sorting. #modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built # documents. #keep_warnings = False # -- Options for HTML output ------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a # theme further. For a list of options available for each theme, see the # documentation. #html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". #html_title = None # A shorter title for the navigation bar. Default is the same as # html_title. #html_short_title = None # The name of an image file (relative to this directory) to place at the # top of the sidebar. #html_logo = None # The name of an image file (within the static path) to use as favicon # of the docs. This file should be a Windows icon file (.ico) being # 16x16 or 32x32 pixels large. #html_favicon = None # Add any paths that contain custom static files (such as style sheets) # here, relative to this directory. They are copied after the builtin # static files, so a file named "default.css" will overwrite the builtin # "default.css". html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page # bottom, using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. #html_use_smartypants = True # Custom sidebar templates, maps document names to template names. #html_sidebars = {} # Additional templates that should be rendered to pages, maps page names # to template names. #html_additional_pages = {} # If false, no module index is generated. #html_domain_indices = True # If false, no index is generated. #html_use_index = True # If true, the index is split into individual pages for each letter. #html_split_index = False # If true, links to the reST sources are added to the pages. #html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. # Default is True. #html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. # Default is True. #html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages # will contain a <link> tag referring to it. The value of this option # must be the base URL from which the finished HTML is served. #html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). #html_file_suffix = None # Output file base name for HTML help builder. htmlhelp_basename = 'rfMHCdoc' # -- Options for LaTeX output ------------------------------------------ latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', # Additional stuff for the LaTeX preamble. #'preamble': '', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ ('index', 'rfMHC.tex', u'rfMHC Documentation', u'David Olivieri', 'manual'), ] # The name of an image file (relative to this directory) to place at # the top of the title page. #latex_logo = None # For "manual" documents, if this is true, then toplevel headings # are parts, not chapters. #latex_use_parts = False # If true, show page references after internal links. #latex_show_pagerefs = False # If true, show URL addresses after external links. #latex_show_urls = False # Documents to append as an appendix to all manuals. #latex_appendices = [] # If false, no module index is generated. #latex_domain_indices = True # -- Options for manual page output ------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ ('index', 'rfMHC', u'rfMHC Documentation', [u'David Olivieri'], 1) ] # If true, show URL addresses after external links. #man_show_urls = False # -- Options for Texinfo output ---------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ('index', 'rfMHC', u'rfMHC Documentation', u'David Olivieri', 'rfMHC', 'One line description of project.', 'Miscellaneous'), ] # Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False
bsd-3-clause
endlessm/chromium-browser
media/capture/video/fake_video_capture_device_factory.h
4027
// Copyright 2014 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_ #define MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_ #include <algorithm> #include <memory> #include <string> #include <utility> #include <vector> #include "media/capture/video/fake_video_capture_device.h" #include "media/capture/video/video_capture_device_factory.h" namespace gpu { class GpuMemoryBufferSupport; } // namespace gpu namespace media { struct CAPTURE_EXPORT FakeVideoCaptureDeviceSettings { FakeVideoCaptureDeviceSettings(); ~FakeVideoCaptureDeviceSettings(); FakeVideoCaptureDeviceSettings(const FakeVideoCaptureDeviceSettings& other); std::string device_id; FakeVideoCaptureDevice::DeliveryMode delivery_mode; VideoCaptureFormats supported_formats; FakePhotoDeviceConfig photo_device_config; FakeVideoCaptureDevice::DisplayMediaType display_media_type; }; // Implementation of VideoCaptureDeviceFactory that creates fake devices // that generate test output frames. // By default, the factory has one device outputting I420 with // USE_DEVICE_INTERNAL_BUFFERS. It supports a default set of resolutions. // When a resolution is requested that is not part of the default set, it snaps // to the resolution with the next larger width. It supports all frame rates // within a default allowed range. class CAPTURE_EXPORT FakeVideoCaptureDeviceFactory : public VideoCaptureDeviceFactory { public: static constexpr const char kDeviceConfigForGetPhotoStateFails[] = "GetPhotoStateFails"; static constexpr const char kDeviceConfigForSetPhotoOptionsFails[] = "SetPhotoOptionsFails"; static constexpr const char kDeviceConfigForTakePhotoFails[] = "TakePhotoFails"; FakeVideoCaptureDeviceFactory(); ~FakeVideoCaptureDeviceFactory() override; static std::unique_ptr<VideoCaptureDevice> CreateDeviceWithSettings( const FakeVideoCaptureDeviceSettings& settings, std::unique_ptr<gpu::GpuMemoryBufferSupport> gmb_support = nullptr); static std::unique_ptr<VideoCaptureDevice> CreateDeviceWithDefaultResolutions( VideoPixelFormat pixel_format, FakeVideoCaptureDevice::DeliveryMode delivery_mode, float frame_rate, std::unique_ptr<gpu::GpuMemoryBufferSupport> gmb_support = nullptr); // Creates a device that reports OnError() when AllocateAndStart() is called. static std::unique_ptr<VideoCaptureDevice> CreateErrorDevice(); static void ParseFakeDevicesConfigFromOptionsString( const std::string options_string, std::vector<FakeVideoCaptureDeviceSettings>* config); // All devices use the default set of resolution, the default range for // allowed frame rates, as well as USE_DEVICE_INTERNAL_BUFFERS. // Device 0 outputs I420. // Device 1 outputs Y16. // Device 2 outputs MJPEG. // All additional devices output I420. void SetToDefaultDevicesConfig(int device_count); void SetToCustomDevicesConfig( const std::vector<FakeVideoCaptureDeviceSettings>& config); // VideoCaptureDeviceFactory implementation: std::unique_ptr<VideoCaptureDevice> CreateDevice( const VideoCaptureDeviceDescriptor& device_descriptor) override; void GetDeviceDescriptors( VideoCaptureDeviceDescriptors* device_descriptors) override; void GetSupportedFormats( const VideoCaptureDeviceDescriptor& device_descriptor, VideoCaptureFormats* supported_formats) override; void GetCameraLocationsAsync( std::unique_ptr<VideoCaptureDeviceDescriptors> device_descriptors, DeviceDescriptorsCallback result_callback) override; int number_of_devices() { DCHECK(thread_checker_.CalledOnValidThread()); return static_cast<int>(devices_config_.size()); } private: std::vector<FakeVideoCaptureDeviceSettings> devices_config_; }; } // namespace media #endif // MEDIA_CAPTURE_VIDEO_FAKE_VIDEO_CAPTURE_DEVICE_FACTORY_H_
bsd-3-clause
hjwylde/scotland-yard
app/policies/game_valid_policy.rb
1062
class GameValidPolicy include Wisper::Publisher def initialize(game:) @game = game @errors = [] end # Policy for determining if the game is valid # The game is valid provided: # 1) the game only ever has at most 1 criminal, # 2) the game only ever has at most Game::NUMBER_OF_PLAYERS and, # 3) if the game has Game::NUMBER_OF_PLAYERS, then the game has exactly 1 criminal def valid? check_player_count_is_valid check_player_types_are_valid publish(:fail, @errors) if @errors.any? @errors.empty? end private def check_player_count_is_valid if @game.players.length > Game::NUMBER_OF_PLAYERS @errors << "Game must have #{Game::NUMBER_OF_PLAYERS} or less players" end end def check_player_types_are_valid unless player_types_are_valid @errors << 'Game may only have 1 criminal' end end def player_types_are_valid if @game.players.length < Game::NUMBER_OF_PLAYERS [email protected]?(&:criminal?) else @game.players.one?(&:criminal?) end end end
bsd-3-clause
exponent/exponent
ios/versioned-react-native/ABI40_0_0/ReactNative/ReactCommon/fabric/core/shadownode/ABI40_0_0Props.cpp
689
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include "ABI40_0_0Props.h" #include <folly/dynamic.h> #include <ABI40_0_0React/core/propsConversions.h> namespace ABI40_0_0facebook { namespace ABI40_0_0React { Props::Props(const Props &sourceProps, const RawProps &rawProps) : nativeId(convertRawProp(rawProps, "nativeID", sourceProps.nativeId, {})), revision(sourceProps.revision + 1) #ifdef ANDROID , rawProps((folly::dynamic)rawProps) #endif {}; } // namespace ABI40_0_0React } // namespace ABI40_0_0facebook
bsd-3-clause
KyoX/UCA_CompiladoresCLIPS
ide/Resultado.h
2523
#pragma once namespace ide { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; /// <summary> /// Summary for Resultado /// </summary> public ref class Resultado : public System::Windows::Forms::Form { public: Resultado(String^ texto) { InitializeComponent(); // //TODO: Add the constructor code here // this->richTextBox1->Text = texto; } protected: /// <summary> /// Clean up any resources being used. /// </summary> ~Resultado() { if (components) { delete components; } } private: System::Windows::Forms::RichTextBox^ richTextBox1; protected: private: /// <summary> /// Required designer variable. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox()); this->SuspendLayout(); // // richTextBox1 // this->richTextBox1->BackColor = System::Drawing::SystemColors::GrayText; this->richTextBox1->Dock = System::Windows::Forms::DockStyle::Fill; this->richTextBox1->ForeColor = System::Drawing::SystemColors::Info; this->richTextBox1->Location = System::Drawing::Point(0, 0); this->richTextBox1->Name = L"richTextBox1"; this->richTextBox1->ReadOnly = true; this->richTextBox1->Size = System::Drawing::Size(375, 542); this->richTextBox1->TabIndex = 0; this->richTextBox1->Text = L""; // // Resultado // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(375, 542); this->Controls->Add(this->richTextBox1); this->MaximizeBox = false; this->MinimizeBox = false; this->Name = L"Resultado"; this->ShowIcon = false; this->ShowInTaskbar = false; this->StartPosition = System::Windows::Forms::FormStartPosition::CenterParent; this->Text = L"Salida scanner"; this->Load += gcnew System::EventHandler(this, &Resultado::Resultado_Load); this->ResumeLayout(false); } #pragma endregion private: System::Void Resultado_Load(System::Object^ sender, System::EventArgs^ e) { } }; }
bsd-3-clause
crosg/idCreator
idcreator/IdcreatorTcpAccept.c
10194
/************************************************************* * _ooOoo_ * o8888888o * 88" . "88 * (| -_- |) * O\ = /O * ____/`---'\____ * .' \\| |// `. * / \\||| : |||// \ * / _||||| -:- |||||- \ * | | \\\ - /// | | * | \_| ''\---/'' | | * \ .-\__ `-` ___/-. / * ___`. .' /--.--\ `. . __ * ."" '< `.___\_<|>_/___.' >'"". * | | : `- \`.;`\ _ /`;.`/ - ` : | | * \ \ `-. \_ __\ /__ _/ .-` / / * ======`-.____`-.___\_____/___.-`____.-'====== * `=---=' * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * 佛祖保佑 永无BUG * * ========================================================================== * * this software or lib may be copied only under the terms of the gnu general * public license v3, which may be found in the source kit. * * Filename: IdcreatorTcpAccept.c * Created: 2015年03月03日 11时27分35秒 * Author: Seapeak.Xu (www.94geek.com), [email protected] * Company: Tencent Literature * Remark: * ***********************************************************************/ #include <stdlib.h> #include <stdio.h> #include <stdlib.h> #include <stddef.h> #include <sys/types.h> #include <sys/socket.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <netinet/tcp.h> #include <netinet/in.h> #include <sys/time.h> #include <string.h> #include <arpa/inet.h> #include <netdb.h> #include <ev.h> #include "spx_types.h" #include "spx_string.h" #include "spx_defs.h" #include "spx_socket.h" #include "spx_module.h" #include "spx_job.h" #include "spx_time.h" #include "spx_alloc.h" #include "spx_io.h" #include "spx_nio.h" #include "IdcreatorTcpAccept.h" #include "IdcreatorConfig.h" #include "IdcreatorServerContext.h" #include "IdcreatorCore.h" #include "IdcreatorProtocol.h" struct mainsocket_thread_arg{ SpxLogDelegate *log; struct IdcreatorConfig *c; }; spx_private struct ev_loop *main_socket_loop = NULL; spx_private ev_io main_watcher; spx_private void *idcreatorTcpCreate(void *arg); spx_private void idcreatorTcpAcceptHandler(struct ev_loop *loop, ev_io *watcher,int revents); spx_private void idcreatorTcpAccept(struct IdcreatorConfig *c,struct ev_loop *loop,int fd); spx_private void idcreatorDispatcherHandler(struct ev_loop *loop,ev_async *w,int revents); spx_private void idcreatorTcpAccept(struct IdcreatorConfig *c,struct ev_loop *loop,int fd){/*{{{*/ SpxZero(main_watcher); ev_io_init(&main_watcher,idcreatorTcpAcceptHandler,fd,EV_READ); main_watcher.data = c; ev_io_start(loop,&(main_watcher)); ev_run(loop,0); }/*}}}*/ spx_private void idcreatorTcpAcceptHandler(struct ev_loop *loop,ev_io *watcher,int revents){/*{{{*/ ev_io_stop(loop,watcher); struct IdcreatorConfig *c = (struct IdcreatorConfig *) watcher->data; // SpxLogDelegate *log = (SpxLogDelegate *) watcher->data; err_t err = 0; while(true){ struct sockaddr_in client_addr; unsigned int socket_len = 0; int client_sock = 0; socket_len = sizeof(struct sockaddr_in); client_sock = accept(watcher->fd, (struct sockaddr *) &client_addr, &socket_len); if (0 > client_sock) { if (EWOULDBLOCK == errno || EAGAIN == errno) { break; } break; } if (0 == client_sock) { break; } struct IdcreatorServerContext *isc = idcreatorServerContextPoolPop(gIdcreatorServerContextPool,&err); if(!isc) { SpxClose(client_sock); SpxLog1(c->log,SpxLogError,\ "pop isc context is fail."); break; } isc->fd = client_sock; isc->loop = loop; ev_once(loop,isc->fd,EV_READ,(ev_tstamp) c->waitting,isc->inHandler,(void *) isc); } ev_io_start(loop,watcher); }/*}}}*/ spx_private void *idcreatorTcpCreate(void *arg){/*{{{*/ struct mainsocket_thread_arg *mainsocket_arg = (struct mainsocket_thread_arg *) arg; SpxLogDelegate *log = mainsocket_arg->log; struct IdcreatorConfig *c= mainsocket_arg->c; SpxFree(mainsocket_arg); err_t err = 0; main_socket_loop = ev_loop_new(0); if(NULL == main_socket_loop){ SpxLog2(log,SpxLogError,err,"create main socket loop is fail."); return NULL; } int mainsocket = spx_socket_new(&err); if(0 == mainsocket){ SpxLog2(log,SpxLogError,err,"create main socket is fail."); return NULL; } if(0!= (err = spx_set_nb(mainsocket))){ SpxLog2(log,SpxLogError,err,"set main socket nonblock is fail."); goto r1; } if(0 != (err = spx_socket_start(mainsocket,c->ip,c->port,\ true,c->timeout,\ 3,c->timeout,\ false,0,\ true,\ true,c->timeout, 1024))){ SpxLog2(log,SpxLogError,err,"start main socket is fail."); goto r1; } SpxLogFmt1(log,SpxLogMark, "main socket fd:%d." "and accepting...", mainsocket); idcreatorTcpAccept(c,main_socket_loop,mainsocket); r1: SpxClose(mainsocket); return NULL; }/*}}}*/ pthread_t idcreatorMainTcpThreadNew(SpxLogDelegate *log,struct IdcreatorConfig *c,err_t *err) {/*{{{*/ pthread_attr_t attr; pthread_attr_init(&attr); size_t ostack_size = 0; pthread_attr_getstacksize(&attr, &ostack_size); if (ostack_size != c->stackSize && (0 != (*err = pthread_attr_setstacksize(&attr,c->stackSize)))){ return 0; } struct mainsocket_thread_arg *arg =(struct mainsocket_thread_arg *) spx_alloc_alone(sizeof(*arg),err); if(NULL == arg){ pthread_attr_destroy(&attr); return 0; } arg->log = log; arg->c = c; pthread_t tid = 0; if (0 !=(*err = pthread_create(&tid, &attr, idcreatorTcpCreate, arg))){ pthread_attr_destroy(&attr); SpxFree(arg); return 0; } pthread_attr_destroy(&attr); return tid; }/*}}}*/ void idcreatorNetworkReceiverHandler(int revents,void *arg) {/*{{{*/ SpxTypeConvert2(struct IdcreatorServerContext,isc,arg); if(NULL == isc){ return; } SpxTypeConvert2(struct IdcreatorConfig,c,isc->c); if(EV_TIMEOUT & revents){ SpxLog1(isc->log,SpxLogError,\ "waitting read from client is timeout." "and then push the server context to pool."); idcreatorServerContextPoolPush(gIdcreatorServerContextPool,isc); return; } err_t err = 0; if(EV_READ & revents){ size_t len = 0; err = spx_read_ack(isc->fd, (byte_t *) isc->inbuf + isc->offset, isc->inlen,&len); if(err) { if(EAGAIN == err || EWOULDBLOCK == err || EINTR == err){ isc->offset += len; ev_once(isc->loop,isc->fd,EV_READ,c->waitting,isc->inHandler,(void *) isc); return; } else { SpxLogFmt2(isc->log,SpxLogError,err, "read body is fail.bodylen:%d,recvlen:%d." "and then push the server context to pool.", isc->inlen,isc->offset); idcreatorServerContextPoolPush(gIdcreatorServerContextPool,isc); return; } } spx_dio_async_launch(isc->loop,&(isc->async),idcreatorDispatcherHandler,isc); return; } return; }/*}}}*/ void idcreatorNetworkSenderHandler(int revents,void *arg) {/*{{{*/ SpxTypeConvert2(struct IdcreatorServerContext,isc,arg); if(NULL == isc){ return; } SpxTypeConvert2(struct IdcreatorConfig,c,isc->c); if(EV_TIMEOUT & revents){ SpxLogFmt1(isc->log,SpxLogError, "wait for writing to client is fail." "bodylen:%d,writed len:%d." "and then push the server context to pool.", isc->outlen,isc->offset); idcreatorServerContextPoolPush(gIdcreatorServerContextPool,isc); return; } err_t err = 0; if(EV_WRITE & revents){ size_t len = 0; err = spx_write_ack(isc->fd, (byte_t *) isc->outbuf + isc->offset, isc->outlen,&len); if(err) { if(EAGAIN == err || EWOULDBLOCK == err || EINTR == err){ isc->offset += len; ev_once(isc->loop,isc->fd,EV_WRITE,c->waitting,isc->outHandler,(void *) isc); return; } else { SpxLogFmt2(isc->log,SpxLogError,err, "wait for writing to client is fail." "bodylen:%d,writed len:%d." "and then push the server context to pool.", isc->outlen,isc->offset); idcreatorServerContextPoolPush(gIdcreatorServerContextPool,isc); return; } } idcreatorServerContextPoolPush(gIdcreatorServerContextPool,isc); } return; }/*}}}*/ spx_private void idcreatorDispatcherHandler(struct ev_loop *loop,ev_async *w,int revents){/*{{{*/ ev_async_stop(loop,w); SpxTypeConvert2(struct IdcreatorServerContext,isc,w->data); err_t err = 0; u64_t id = 0l; int type = 0; type = spx_msg_b2i((uchar_t *) isc->inbuf + SpxMsgHeaderSize); SpxTypeConvert2(struct IdcreatorConfig,c,isc->c); if((0x4ff != type) && (0 > type || 0x3ff < type)){ type = 0x3ff; } int mid = c->mid; id = IdGenerator(type, mid, &err); isc->outheader.version = IdcreatorVersion; isc->outheader.protocol = IdcreatorMakeId; isc->outheader.bodylen = sizeof(u64_t); spx_header_pack(isc->outbuf,&(isc->outheader)); spx_msg_ul2b((uchar_t *) isc->outbuf + SpxMsgHeaderSize,id); idcreatorNetworkSenderHandler(EV_WRITE,isc); return; }/*}}}*/
bsd-3-clause
lejard-h/polymer_app_layout_templates
doc/api/polymer_app_layout.behaviors/Element/setInnerHtml.html
33566
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>setInnerHtml method - Element class - polymer_app_layout.behaviors library - Dart API</title> <!-- required because all the links are pseudo-absolute --> <base href="../.."> <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro|Roboto:500,400italic,300,400' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="static-assets/prettify.css"> <link rel="stylesheet" href="static-assets/css/bootstrap.min.css"> <link rel="stylesheet" href="static-assets/styles.css"> <meta name="description" content="API docs for the setInnerHtml method from the Element class, for the Dart programming language."> <link rel="icon" href="static-assets/favicon.png"> <!-- Do not remove placeholder --> <!-- Header Placeholder --> </head> <body> <div id="overlay-under-drawer"></div> <header class="container-fluid" id="title"> <nav class="navbar navbar-fixed-top"> <div class="container"> <button id="sidenav-left-toggle" type="button">&nbsp;</button> <ol class="breadcrumbs gt-separated hidden-xs"> <li><a href="index.html">polymer_app_layout_template</a></li> <li><a href="polymer_app_layout.behaviors/polymer_app_layout.behaviors-library.html">polymer_app_layout.behaviors</a></li> <li><a href="polymer_app_layout.behaviors/Element-class.html">Element</a></li> <li class="self-crumb">setInnerHtml</li> </ol> <div class="self-name">setInnerHtml</div> </div> </nav> <div class="container masthead"> <ol class="breadcrumbs gt-separated visible-xs"> <li><a href="index.html">polymer_app_layout_template</a></li> <li><a href="polymer_app_layout.behaviors/polymer_app_layout.behaviors-library.html">polymer_app_layout.behaviors</a></li> <li><a href="polymer_app_layout.behaviors/Element-class.html">Element</a></li> <li class="self-crumb">setInnerHtml</li> </ol> <div class="title-description"> <h1 class="title"> <div class="kind">method</div> setInnerHtml </h1> <!-- p class="subtitle"> Parses the HTML fragment and sets it as the contents of this element. This ensures that the generated content follows the sanitization rules specified by the validator or treeSanitizer. </p --> </div> <ul class="subnav"> <li><a href="polymer_app_layout.behaviors/Element/setInnerHtml.html#source">Source</a></li> </ul> </div> </header> <div class="container body"> <div class="col-xs-6 col-sm-3 sidebar sidebar-offcanvas-left"> <h5><a href="index.html">polymer_app_layout_template</a></h5> <h5><a href="polymer_app_layout.behaviors/polymer_app_layout.behaviors-library.html">polymer_app_layout.behaviors</a></h5> <h5><a href="polymer_app_layout.behaviors/Element-class.html">Element</a></h5> <ol> <li class="section-title"><a href="polymer_app_layout.behaviors/Element-class.html#constants">Constants</a></li> <li><a href="polymer_app_layout.behaviors/Element/abortEvent.html">abortEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/beforeCopyEvent.html">beforeCopyEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/beforeCutEvent.html">beforeCutEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/beforePasteEvent.html">beforePasteEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/blurEvent.html">blurEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/canPlayEvent.html">canPlayEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/canPlayThroughEvent.html">canPlayThroughEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/changeEvent.html">changeEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/clickEvent.html">clickEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/contextMenuEvent.html">contextMenuEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/copyEvent.html">copyEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/cutEvent.html">cutEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/doubleClickEvent.html">doubleClickEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/dragEndEvent.html">dragEndEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/dragEnterEvent.html">dragEnterEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/dragEvent.html">dragEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/dragLeaveEvent.html">dragLeaveEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/dragOverEvent.html">dragOverEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/dragStartEvent.html">dragStartEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/dropEvent.html">dropEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/durationChangeEvent.html">durationChangeEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/emptiedEvent.html">emptiedEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/endedEvent.html">endedEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/errorEvent.html">errorEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/focusEvent.html">focusEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/fullscreenChangeEvent.html">fullscreenChangeEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/fullscreenErrorEvent.html">fullscreenErrorEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/inputEvent.html">inputEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/invalidEvent.html">invalidEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/keyDownEvent.html">keyDownEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/keyPressEvent.html">keyPressEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/keyUpEvent.html">keyUpEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/loadedDataEvent.html">loadedDataEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/loadedMetadataEvent.html">loadedMetadataEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/loadEvent.html">loadEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/mouseDownEvent.html">mouseDownEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/mouseEnterEvent.html">mouseEnterEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/mouseLeaveEvent.html">mouseLeaveEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/mouseMoveEvent.html">mouseMoveEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/mouseOutEvent.html">mouseOutEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/mouseOverEvent.html">mouseOverEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/mouseUpEvent.html">mouseUpEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/mouseWheelEvent.html">mouseWheelEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/pasteEvent.html">pasteEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/pauseEvent.html">pauseEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/playEvent.html">playEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/playingEvent.html">playingEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/rateChangeEvent.html">rateChangeEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/resetEvent.html">resetEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/resizeEvent.html">resizeEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/scrollEvent.html">scrollEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/searchEvent.html">searchEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/seekedEvent.html">seekedEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/seekingEvent.html">seekingEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/selectEvent.html">selectEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/selectStartEvent.html">selectStartEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/stalledEvent.html">stalledEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/submitEvent.html">submitEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/suspendEvent.html">suspendEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/timeUpdateEvent.html">timeUpdateEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/touchCancelEvent.html">touchCancelEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/touchEndEvent.html">touchEndEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/touchEnterEvent.html">touchEnterEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/touchLeaveEvent.html">touchLeaveEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/touchMoveEvent.html">touchMoveEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/touchStartEvent.html">touchStartEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/transitionEndEvent.html">transitionEndEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/volumeChangeEvent.html">volumeChangeEvent</a></li> <li><a href="polymer_app_layout.behaviors/Element/waitingEvent.html">waitingEvent</a></li> <li class="section-title"><a href="polymer_app_layout.behaviors/Element-class.html#static-methods">Static methods</a></li> <li><a href="polymer_app_layout.behaviors/Element/isTagSupported.html">isTagSupported</a></li> <li class="section-title"><a href="polymer_app_layout.behaviors/Element-class.html#instance-properties">Properties</a></li> <li><a href="polymer_app_layout.behaviors/Element/attributes.html">attributes</a> </li> <li>baseUri </li> <li><a href="polymer_app_layout.behaviors/Element/borderEdge.html">borderEdge</a> </li> <li>childNodes </li> <li><a href="polymer_app_layout.behaviors/Element/children.html">children</a> </li> <li><a href="polymer_app_layout.behaviors/Element/classes.html">classes</a> </li> <li><a href="polymer_app_layout.behaviors/Element/className.html">className</a> </li> <li><a href="polymer_app_layout.behaviors/Element/client.html">client</a> </li> <li><a href="polymer_app_layout.behaviors/Element/clientHeight.html">clientHeight</a> </li> <li><a href="polymer_app_layout.behaviors/Element/clientLeft.html">clientLeft</a> </li> <li><a href="polymer_app_layout.behaviors/Element/clientTop.html">clientTop</a> </li> <li><a href="polymer_app_layout.behaviors/Element/clientWidth.html">clientWidth</a> </li> <li><a href="polymer_app_layout.behaviors/Element/contentEdge.html">contentEdge</a> </li> <li><a href="polymer_app_layout.behaviors/Element/contentEditable.html">contentEditable</a> </li> <li><a href="polymer_app_layout.behaviors/Element/contextMenu.html">contextMenu</a> </li> <li><a href="polymer_app_layout.behaviors/Element/dataset.html">dataset</a> </li> <li><a href="polymer_app_layout.behaviors/Element/dir.html">dir</a> </li> <li><a href="polymer_app_layout.behaviors/Element/documentOffset.html">documentOffset</a> </li> <li><a href="polymer_app_layout.behaviors/Element/draggable.html">draggable</a> </li> <li><a href="polymer_app_layout.behaviors/Element/dropzone.html">dropzone</a> </li> <li>firstChild </li> <li><a href="polymer_app_layout.behaviors/Element/hidden.html">hidden</a> </li> <li><a href="polymer_app_layout.behaviors/Element/id.html">id</a> </li> <li><a href="polymer_app_layout.behaviors/Element/innerHtml.html">innerHtml</a> </li> <li><a href="polymer_app_layout.behaviors/Element/isContentEditable.html">isContentEditable</a> </li> <li><a href="polymer_app_layout.behaviors/Element/lang.html">lang</a> </li> <li>lastChild </li> <li><a href="polymer_app_layout.behaviors/Element/localName.html">localName</a> </li> <li><a href="polymer_app_layout.behaviors/Element/marginEdge.html">marginEdge</a> </li> <li><a href="polymer_app_layout.behaviors/Element/namespaceUri.html">namespaceUri</a> </li> <li><a href="polymer_app_layout.behaviors/Element/nextElementSibling.html">nextElementSibling</a> </li> <li>nextNode </li> <li>nodeName </li> <li>nodes </li> <li>nodeType </li> <li>nodeValue </li> <li><a href="polymer_app_layout.behaviors/Element/offset.html">offset</a> </li> <li><a href="polymer_app_layout.behaviors/Element/offsetHeight.html">offsetHeight</a> </li> <li><a href="polymer_app_layout.behaviors/Element/offsetLeft.html">offsetLeft</a> </li> <li><a href="polymer_app_layout.behaviors/Element/offsetParent.html">offsetParent</a> </li> <li><a href="polymer_app_layout.behaviors/Element/offsetTop.html">offsetTop</a> </li> <li><a href="polymer_app_layout.behaviors/Element/offsetWidth.html">offsetWidth</a> </li> <li><a href="polymer_app_layout.behaviors/Element/on.html">on</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onAbort.html">onAbort</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onBeforeCopy.html">onBeforeCopy</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onBeforeCut.html">onBeforeCut</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onBeforePaste.html">onBeforePaste</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onBlur.html">onBlur</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onCanPlay.html">onCanPlay</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onCanPlayThrough.html">onCanPlayThrough</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onChange.html">onChange</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onClick.html">onClick</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onContextMenu.html">onContextMenu</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onCopy.html">onCopy</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onCut.html">onCut</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDoubleClick.html">onDoubleClick</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDrag.html">onDrag</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDragEnd.html">onDragEnd</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDragEnter.html">onDragEnter</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDragLeave.html">onDragLeave</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDragOver.html">onDragOver</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDragStart.html">onDragStart</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDrop.html">onDrop</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onDurationChange.html">onDurationChange</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onEmptied.html">onEmptied</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onEnded.html">onEnded</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onError.html">onError</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onFocus.html">onFocus</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onFullscreenChange.html">onFullscreenChange</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onFullscreenError.html">onFullscreenError</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onInput.html">onInput</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onInvalid.html">onInvalid</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onKeyDown.html">onKeyDown</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onKeyPress.html">onKeyPress</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onKeyUp.html">onKeyUp</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onLoad.html">onLoad</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onLoadedData.html">onLoadedData</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onLoadedMetadata.html">onLoadedMetadata</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onMouseDown.html">onMouseDown</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onMouseEnter.html">onMouseEnter</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onMouseLeave.html">onMouseLeave</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onMouseMove.html">onMouseMove</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onMouseOut.html">onMouseOut</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onMouseOver.html">onMouseOver</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onMouseUp.html">onMouseUp</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onMouseWheel.html">onMouseWheel</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onPaste.html">onPaste</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onPause.html">onPause</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onPlay.html">onPlay</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onPlaying.html">onPlaying</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onRateChange.html">onRateChange</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onReset.html">onReset</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onResize.html">onResize</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onScroll.html">onScroll</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onSearch.html">onSearch</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onSeeked.html">onSeeked</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onSeeking.html">onSeeking</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onSelect.html">onSelect</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onSelectStart.html">onSelectStart</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onStalled.html">onStalled</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onSubmit.html">onSubmit</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onSuspend.html">onSuspend</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onTimeUpdate.html">onTimeUpdate</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onTouchCancel.html">onTouchCancel</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onTouchEnd.html">onTouchEnd</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onTouchEnter.html">onTouchEnter</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onTouchLeave.html">onTouchLeave</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onTouchMove.html">onTouchMove</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onTouchStart.html">onTouchStart</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onTransitionEnd.html">onTransitionEnd</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onVolumeChange.html">onVolumeChange</a> </li> <li><a href="polymer_app_layout.behaviors/Element/onWaiting.html">onWaiting</a> </li> <li><a href="polymer_app_layout.behaviors/Element/outerHtml.html">outerHtml</a> </li> <li>ownerDocument </li> <li><a href="polymer_app_layout.behaviors/Element/paddingEdge.html">paddingEdge</a> </li> <li>parent </li> <li>parentNode </li> <li><a href="polymer_app_layout.behaviors/Element/previousElementSibling.html">previousElementSibling</a> </li> <li>previousNode </li> <li><a href="polymer_app_layout.behaviors/Element/scrollHeight.html">scrollHeight</a> </li> <li><a href="polymer_app_layout.behaviors/Element/scrollLeft.html">scrollLeft</a> </li> <li><a href="polymer_app_layout.behaviors/Element/scrollTop.html">scrollTop</a> </li> <li><a href="polymer_app_layout.behaviors/Element/scrollWidth.html">scrollWidth</a> </li> <li><a href="polymer_app_layout.behaviors/Element/shadowRoot.html">shadowRoot</a> </li> <li><a href="polymer_app_layout.behaviors/Element/spellcheck.html">spellcheck</a> </li> <li><a href="polymer_app_layout.behaviors/Element/style.html">style</a> </li> <li><a href="polymer_app_layout.behaviors/Element/tabIndex.html">tabIndex</a> </li> <li><a href="polymer_app_layout.behaviors/Element/tagName.html">tagName</a> </li> <li>text </li> <li><a href="polymer_app_layout.behaviors/Element/title.html">title</a> </li> <li><a href="polymer_app_layout.behaviors/Element/translate.html">translate</a> </li> <li><a href="polymer_app_layout.behaviors/Element/xtag.html">xtag</a> </li> <li class="section-title"><a href="polymer_app_layout.behaviors/Element-class.html#constructors">Constructors</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.a.html">a</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.article.html">article</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.aside.html">aside</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.audio.html">audio</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.br.html">br</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.canvas.html">canvas</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.created.html">created</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.div.html">div</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.footer.html">footer</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.header.html">header</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.hr.html">hr</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.html.html">html</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.iframe.html">iframe</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.img.html">img</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.li.html">li</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.nav.html">nav</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.ol.html">ol</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.option.html">option</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.p.html">p</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.pre.html">pre</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.section.html">section</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.select.html">select</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.span.html">span</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.svg.html">svg</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.table.html">table</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.tag.html">tag</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.td.html">td</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.textarea.html">textarea</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.th.html">th</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.tr.html">tr</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.ul.html">ul</a></li> <li><a href="polymer_app_layout.behaviors/Element/Element.video.html">video</a></li> <li class="section-title"><a href="polymer_app_layout.behaviors/Element-class.html#methods">Methods</a></li> <li>addEventListener </li> <li><a href="polymer_app_layout.behaviors/Element/animate.html">animate</a> </li> <li>append </li> <li><a href="polymer_app_layout.behaviors/Element/appendHtml.html">appendHtml</a> </li> <li><a href="polymer_app_layout.behaviors/Element/appendText.html">appendText</a> </li> <li><a href="polymer_app_layout.behaviors/Element/attached.html">attached</a> </li> <li><a href="polymer_app_layout.behaviors/Element/attributeChanged.html">attributeChanged</a> </li> <li><a href="polymer_app_layout.behaviors/Element/blur.html">blur</a> </li> <li><a href="polymer_app_layout.behaviors/Element/click.html">click</a> </li> <li>clone </li> <li>contains </li> <li><a href="polymer_app_layout.behaviors/Element/createFragment.html">createFragment</a> </li> <li><a href="polymer_app_layout.behaviors/Element/createShadowRoot.html">createShadowRoot</a> </li> <li><a href="polymer_app_layout.behaviors/Element/detached.html">detached</a> </li> <li>dispatchEvent </li> <li><a href="polymer_app_layout.behaviors/Element/enteredView.html">enteredView</a> </li> <li><a href="polymer_app_layout.behaviors/Element/focus.html">focus</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getAnimationPlayers.html">getAnimationPlayers</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getAttribute.html">getAttribute</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getAttributeNS.html">getAttributeNS</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getBoundingClientRect.html">getBoundingClientRect</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getClientRects.html">getClientRects</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getComputedStyle.html">getComputedStyle</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getDestinationInsertionPoints.html">getDestinationInsertionPoints</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getElementsByClassName.html">getElementsByClassName</a> </li> <li><a href="polymer_app_layout.behaviors/Element/getNamespacedAttributes.html">getNamespacedAttributes</a> </li> <li>hasChildNodes </li> <li><a href="polymer_app_layout.behaviors/Element/insertAdjacentElement.html">insertAdjacentElement</a> </li> <li><a href="polymer_app_layout.behaviors/Element/insertAdjacentHtml.html">insertAdjacentHtml</a> </li> <li><a href="polymer_app_layout.behaviors/Element/insertAdjacentText.html">insertAdjacentText</a> </li> <li>insertAllBefore </li> <li>insertBefore </li> <li><a href="polymer_app_layout.behaviors/Element/leftView.html">leftView</a> </li> <li><a href="polymer_app_layout.behaviors/Element/matches.html">matches</a> </li> <li><a href="polymer_app_layout.behaviors/Element/matchesWithAncestors.html">matchesWithAncestors</a> </li> <li><a href="polymer_app_layout.behaviors/Element/offsetTo.html">offsetTo</a> </li> <li><a href="polymer_app_layout.behaviors/Element/query.html">query</a> </li> <li><a href="polymer_app_layout.behaviors/Element/queryAll.html">queryAll</a> </li> <li><a href="polymer_app_layout.behaviors/Element/querySelector.html">querySelector</a> </li> <li><a href="polymer_app_layout.behaviors/Element/querySelectorAll.html">querySelectorAll</a> </li> <li><a href="polymer_app_layout.behaviors/Element/remove.html">remove</a> </li> <li>removeEventListener </li> <li>replaceWith </li> <li><a href="polymer_app_layout.behaviors/Element/requestFullscreen.html">requestFullscreen</a> </li> <li><a href="polymer_app_layout.behaviors/Element/requestPointerLock.html">requestPointerLock</a> </li> <li><a href="polymer_app_layout.behaviors/Element/scrollIntoView.html">scrollIntoView</a> </li> <li><a href="polymer_app_layout.behaviors/Element/setAttribute.html">setAttribute</a> </li> <li><a href="polymer_app_layout.behaviors/Element/setAttributeNS.html">setAttributeNS</a> </li> <li><a href="polymer_app_layout.behaviors/Element/setInnerHtml.html">setInnerHtml</a> </li> <li><a href="polymer_app_layout.behaviors/Element/toString.html">toString</a> </li> </ol> </div><!--/.sidebar-offcanvas--> <div class="col-xs-12 col-sm-9 col-md-6 main-content"> <section class="multi-line-signature"> <span class="returntype">void</span> <span class="name ">setInnerHtml</span>( <br> <div class="parameters"> <span class="parameter" id="setInnerHtml-param-html"><span class="type-annotation">String</span> <span class="parameter-name">html</span></span>,<br>{<span class="parameter" id="setInnerHtml-param-validator"><span class="type-annotation"><a href="polymer_app_layout/NodeValidator-class.html">NodeValidator</a></span> <span class="parameter-name">validator</span></span>,<br><span class="parameter" id="setInnerHtml-param-treeSanitizer"><span class="type-annotation"><a href="polymer_app_layout/NodeTreeSanitizer-class.html">NodeTreeSanitizer</a></span> <span class="parameter-name">treeSanitizer</span></span>} </div> ) </section> <section class="desc markdown"> <p>Parses the HTML fragment and sets it as the contents of this element. This ensures that the generated content follows the sanitization rules specified by the validator or treeSanitizer.</p> <p>If the default validation behavior is too restrictive then a new NodeValidator should be created, either extending or wrapping a default validator and overriding the validation APIs.</p> <p>The treeSanitizer is used to walk the generated node tree and sanitize it. A custom treeSanitizer can also be provided to perform special validation rules but since the API is more complex to implement this is discouraged.</p> <p>The resulting tree is guaranteed to only contain nodes and attributes which are allowed by the provided validator.</p> <p>See also:</p><ul><li><a href="polymer_app_layout/NodeValidator-class.html">NodeValidator</a></li><li><a href="polymer_app_layout/NodeTreeSanitizer-class.html">NodeTreeSanitizer</a></li></ul> </section> <section class="summary source-code" id="source"> <h2>Source</h2> <pre><code class="prettyprint lang-dart">/** * Parses the HTML fragment and sets it as the contents of this element. * This ensures that the generated content follows the sanitization rules * specified by the validator or treeSanitizer. * * If the default validation behavior is too restrictive then a new * NodeValidator should be created, either extending or wrapping a default * validator and overriding the validation APIs. * * The treeSanitizer is used to walk the generated node tree and sanitize it. * A custom treeSanitizer can also be provided to perform special validation * rules but since the API is more complex to implement this is discouraged. * * The resulting tree is guaranteed to only contain nodes and attributes which * are allowed by the provided validator. * * See also: * * * [NodeValidator] * * [NodeTreeSanitizer] */ void setInnerHtml(String html, {NodeValidator validator, NodeTreeSanitizer treeSanitizer}) { text = null; if (treeSanitizer is _TrustedHtmlTreeSanitizer) { _innerHtml = html; } else { append(createFragment( html, validator: validator, treeSanitizer: treeSanitizer)); } }</code></pre> </section> </div> <!-- /.main-content --> </div> <!-- container --> <footer> <div class="container-fluid"> <div class="container"> <p class="text-center"> <span class="no-break"> polymer_app_layout_template 0.1.0 api docs </span> &bull; <span class="copyright no-break"> <a href="https://www.dartlang.org"> <img src="static-assets/favicon.png" alt="Dart" title="Dart"width="16" height="16"> </a> </span> &bull; <span class="copyright no-break"> <a href="http://creativecommons.org/licenses/by-sa/4.0/">cc license</a> </span> </p> </div> </div> </footer> <script src="static-assets/prettify.js"></script> <script src="static-assets/script.js"></script> <!-- Do not remove placeholder --> <!-- Footer Placeholder --> </body> </html>
bsd-3-clause
oswen244/proserpaz
models/PagosPrestamosSearch.php
1662
<?php namespace app\models; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use app\models\PagosPrestamos; /** * PagosPrestamosSearch represents the model behind the search form about `app\models\PagosPrestamos`. */ class PagosPrestamosSearch extends PagosPrestamos { /** * @inheritdoc */ public function rules() { return [ [['id_pagos', 'id_prestamo'], 'integer'], [['capital', 'valor_cuota', 'interes', 'amortizacion'], 'number'], [['fecha'], 'safe'], ]; } /** * @inheritdoc */ public function scenarios() { // bypass scenarios() implementation in the parent class return Model::scenarios(); } /** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params,$id_prestamo) { $query = PagosPrestamos::find()->where('id_prestamo=:id'); $query->addParams([':id' => $id_prestamo]); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere([ 'id_pagos' => $this->id_pagos, 'capital' => $this->capital, 'valor_cuota' => $this->valor_cuota, 'fecha' => $this->fecha, 'id_prestamo' => $this->id_prestamo, 'interes' => $this->interes, 'amortizacion' => $this->amortizacion, ]); return $dataProvider; } }
bsd-3-clause
RomarioLopezC/RobotSS
migrations/m160130_212648_add_enrollment_to_student.php
538
<?php use yii\db\Schema; use yii\db\Migration; class m160130_212648_add_enrollment_to_student extends Migration { public function up() { $this->addColumn('student', 'enrollment_id', $this->string()); } public function down() { echo "m160130_212648_add_enrollment_to_student cannot be reverted.\n"; return false; } /* // Use safeUp/safeDown to run migration code within a transaction public function safeUp() { } public function safeDown() { } */ }
bsd-3-clause
richardcornish/cyndiloza
cyndiloza/static/js/site.js
1360
$(document).ready(function(){ // Navigation var body_class = document.body.className; var hover_on_bg = "#c00"; var hover_on_co = "#fff"; var hover_off_bg = "#fff"; var hover_off_co = "#444"; var hover_delay = 200; $("#navigation li a").removeClass("hover"); $("#navigation li").each(function(){ if (this.className == body_class) { $('a', this).addClass("hover"); } else { $(this).hover(function(){ $('a', this).stop().animate({ backgroundColor: hover_on_bg, color: hover_on_co }, hover_delay); }, function(){ $('a', this).stop().animate({ backgroundColor: hover_off_bg, color: hover_off_co }, hover_delay); }); $(this).focus(function(){ $('a', this).stop().animate({ backgroundColor: hover_on_bg, color: hover_on_co }, hover_delay); }, function(){ $('a', this).stop().animate({ backgroundColor: hover_off_bg, color: hover_off_co }, hover_delay); }); } }); // About page first paragraph and clincher $("body.about div#article p:first").addClass("first"); $("body.about div#article p:last").append("<span class=\"clincher\">&#9632;</span>"); }); // E-mail address DOM insertion function email(email){ $("body.about div#article h4:eq(1)").before("<p><strong><a href=\"mailto:" + email + "\">" + email + "</a></strong></p>"); }
bsd-3-clause
udhos/sipswitchd
win-build.cmd
275
set DEVEL=c:\tmp\devel set ROOT=%DEVEL%\sipswitchd set SRC=%ROOT%\src set GOPATH=%ROOT% @rem pushd %SRC% @rem hg clone https://[email protected]/sdr/sip_parser @rem move sip_parser\src\*.* sip_parser @rem popd gofmt -s -w %SRC% go install sip_parser go install sipswitchd
bsd-3-clause
vercas/vLogs
vLogs/Objects/KeyValues/KeyValue Collection.cs
14660
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace vLogs.Objects.KeyValues { /// <summary> /// Represents a collection of key/value pairs. This class cannot be inherited. /// </summary> public sealed class KeyValueCollection : IList<KeyValuePair> { private KeyValuePair[] _arr; int count = 0; bool locked = false; private void _Double() { var temp = _arr; _arr = new KeyValuePair[temp.Length * 2]; Array.Copy(temp, _arr, temp.Length); } #region IList<KeyValuePair> Members /// <summary> /// Determines the index of a specific key/value pair in the collection. /// </summary> /// <param name="item"></param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Thrown when the given item is null.</exception> public int IndexOf(KeyValuePair item) { if (item == null) throw new ArgumentNullException("item"); for (int i = 0; i < count; i++) if (_arr[i] == item) return i; return -1; } /// <summary> /// Inserts a key/value pair to the collection at the specified index. /// </summary> /// <param name="index"></param> /// <param name="item"></param> /// <exception cref="System.ArgumentNullException">Thrown when the given item is null.</exception> /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the given index is negative or greater than the number of items in the collection.</exception> /// <exception cref="System.InvalidOperationException">Thrown when the collection is locked (read-only).</exception> public void Insert(int index, KeyValuePair item) { if (locked) throw new InvalidOperationException("The collection is locked (read-only)."); if (index < 0 || index > count) throw new ArgumentOutOfRangeException("index", "Given index must not be nagative or greater than the number of items in the collection."); if (item == null) throw new ArgumentNullException("item"); for (int i = 0; i < count; i++) if (_arr[i].Key == item.Key) throw new ArgumentException("A key/value pair with the key of the given item already exists in the collection."); if (count == _arr.Length) _Double(); for (int i = count; i > index; i--) _arr[i] = _arr[i - 1]; _arr[index] = item; count++; } /// <summary> /// Removes the key/value pair at the specified index. /// </summary> /// <param name="index"></param> /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the given index is negative or greater than or equal to the number of items in the collection.</exception> /// <exception cref="System.InvalidOperationException">Thrown when the collection is locked (read-only).</exception> public void RemoveAt(int index) { if (locked) throw new InvalidOperationException("The collection is locked (read-only)."); if (index < 0 || index >= count) throw new ArgumentOutOfRangeException("index", "Given index must be positive and less than the number of items in the collection."); for (int i = index; i < count - 1; i++) _arr[i] = _arr[i + 1]; _arr[count - 1] = null; count--; } /// <summary> /// Gets or sets the key/value pair at the specified index. /// </summary> /// <param name="index"></param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Thrown when the given value is null.</exception> /// <exception cref="System.IndexOutOfRangeException">Thrown when the given index is negative or greater than or equal to the number of items in the collection.</exception> /// <exception cref="System.InvalidOperationException">Thrown when setting and the collection is locked (read-only).</exception> public KeyValuePair this[int index] { get { if (index < 0 || index > count) throw new IndexOutOfRangeException("Given index must be positive and less than the number of items in the collection."); return _arr[index]; } set { if (locked) throw new InvalidOperationException("The collection is locked (read-only)."); if (index < 0 || index > count) throw new IndexOutOfRangeException("Given index must be positive and less than the number of items in the collection."); if (value == null) throw new ArgumentNullException("value"); for (int i = 0; i < count; i++) if (i != index && _arr[i].Key == value.Key) throw new ArgumentException("A key/value pair with the key of the given item already exists in the collection."); _arr[index] = value; } } #endregion #region ICollection<KeyValuePair> Members /// <summary> /// Adds a key/value pair to the collection. /// </summary> /// <param name="item"></param> /// <exception cref="System.ArgumentNullException">Thrown when the given item is null.</exception> /// <exception cref="System.InvalidOperationException">Thrown when the collection is locked (read-only).</exception> public void Add(KeyValuePair item) { if (locked) throw new InvalidOperationException("The collection is locked (read-only)."); if (item == null) throw new ArgumentNullException("item"); for (int i = 0; i < count; i++) if (_arr[i].Key == item.Key) throw new ArgumentException("A key/value pair with the key of the given item already exists in the collection."); if (count == _arr.Length) _Double(); _arr[count] = item; count++; } /// <summary> /// Removes all key/value pairs from the collection. /// </summary> /// <exception cref="System.InvalidOperationException">Thrown when the collection is locked (read-only).</exception> public void Clear() { if (locked) throw new InvalidOperationException("The collection is locked (read-only)."); for (int i = 0; i < count; i++) _arr[i] = null; count = 0; } /// <summary> /// Determines whether the collection contains a specific key/value pair. /// </summary> /// <param name="item"></param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Thrown when the given item is null.</exception> public bool Contains(KeyValuePair item) { if (item == null) throw new ArgumentNullException("item"); for (int i = 0; i < count; i++) if (_arr[i] == item) return true; return false; } /// <summary> /// Copies the elements of the collection to an <see cref="System.Array"/>, starting at a particular index. /// </summary> /// <param name="array"></param> /// <param name="arrayIndex"></param> /// <exception cref="System.ArgumentNullException">Thrown when the given array is null.</exception> /// <exception cref="System.ArgumentOutOfRangeException">Thrown when the given array index is negative or would not leave enough room to copy all the items in the collection to the destination array.</exception> public void CopyTo(KeyValuePair[] array, int arrayIndex) { if (array == null) throw new ArgumentNullException("array"); if (arrayIndex < 0 || arrayIndex >= array.Length - count) throw new ArgumentOutOfRangeException("arrayIndex", "Given index must be positive and must allow room for all pairs in the collection for copying."); Array.Copy(_arr, 0, array, arrayIndex, count); } /// <summary> /// Gets the number of elements contained in the collection. /// </summary> public int Count { get { return count; } } /// <summary> /// Gets a value indicating whether the collection is read-only. /// </summary> public bool IsReadOnly { get { return locked; } } /// <summary> /// Removes the specific key/value pair from the collection. /// </summary> /// <param name="item"></param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">Thrown when the given item is null.</exception> /// <exception cref="System.InvalidOperationException">Thrown when the collection is locked (read-only).</exception> public bool Remove(KeyValuePair item) { if (locked) throw new InvalidOperationException("The collection is locked (read-only)."); for (int j = 0; j < count; j++) if (_arr[j] == item) { for (int i = j; i < count - 1; i++) _arr[i] = _arr[i + 1]; _arr[count - 1] = null; count--; return true; } return false; } #endregion #region IEnumerable<KeyValuePair> Members /// <summary> /// Returns an enumerator that iterates through the collection. /// </summary> /// <returns></returns> public IEnumerator<KeyValuePair> GetEnumerator() { for (int i = 0; i < count; i++) yield return _arr[i]; } #endregion #region IEnumerable Members System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { for (int i = 0; i < count; i++) yield return _arr[i]; } #endregion #region Constructors /// <summary> /// Initializes a new instance of the <see cref="vLogs.Objects.KeyValues.KeyValueCollection"/> class. /// </summary> public KeyValueCollection() { this._arr = new KeyValuePair[2]; } /// <summary> /// Initializes a new instance of the <see cref="vLogs.Objects.KeyValues.KeyValueCollection"/> class from the given enumeration of <see cref="vLogs.Objects.KeyValues.KeyValuePair"/>s and an optional indication whether the collection should be locked or not. /// </summary> /// <param name="kvps"></param> /// <param name="locked">optional; True to lock the collection (making it read-only); otherwise false.</param> /// <exception cref="System.ArgumentNullException">Thrown when the given enumeration is null.</exception> /// <exception cref="System.ArgumentException">Thrown when the given enumeration contains two pairs with the same key.</exception> public KeyValueCollection(IEnumerable<KeyValuePair> kvps, bool locked = false) { if (kvps == null) throw new ArgumentNullException("kvps"); this._arr = kvps.ToArray(); this.count = this._arr.Length; for (int i = 0; i < count; i++) for (int j = 0; j < count; j++) if (i != j && this._arr[i].Key == this._arr[j].Key) throw new ArgumentException("The given enumeration of key/value pairs contains two pairs with the same key."); if (count == 0) this._arr = new KeyValuePair[2]; this.locked = locked; } /// <summary> /// Initializes a new instance of the <see cref="vLogs.Objects.KeyValues.KeyValueCollection"/> class from the given enumeration of <see cref="vLogs.Objects.KeyValues.KeyValuePair"/>s and an optional indication whether the collection should be locked or not. /// </summary> /// <param name="locked">True to lock the collection (making it read-only); otherwise false.</param> /// <param name="kvps"></param> /// <exception cref="System.ArgumentNullException">Thrown when the given enumeration is null.</exception> /// <exception cref="System.ArgumentException">Thrown when the given array contains two pairs with the same key.</exception> public KeyValueCollection(bool locked, params KeyValuePair[] kvps) { if (kvps == null) throw new ArgumentNullException("kvps"); for (int i = 0; i < kvps.Length; i++) for (int j = 0; j < kvps.Length; j++) if (i != j && kvps[i].Key == kvps[j].Key) throw new ArgumentException("The given enumeration of key/value pairs contains two pairs with the same key."); this.count = kvps.Length; this._arr = new KeyValuePair[this.count]; if (this.count == 0) this._arr = new KeyValuePair[2]; else Array.Copy(kvps, this._arr, this.count); this.locked = locked; } #endregion /// <summary> /// Locks the collection, making it read-only. /// </summary> /// <exception cref="System.InvalidOperationException">Thrown when the collection is already locked (read-only).</exception> public void Lock() { if (this.locked) throw new InvalidOperationException("The collection is already locked."); this.locked = true; } } }
bsd-3-clause
mirego/activerecord_json_validator
spec/json_validator_spec.rb
3214
# frozen_string_literal: true # rubocop:disable Metrics/BlockLength require 'spec_helper' describe JsonValidator do describe :validate_each do before do run_migration do create_table(:users, force: true) do |t| t.text :data end end spawn_model 'User' do schema = ' { "type": "object", "properties": { "city": { "type": "string" }, "country": { "type": "string" } }, "required": ["country"] } ' serialize :data, JSON validates :data, json: { schema: schema, message: ->(errors) { errors.map { |error| error['details'].to_a.flatten.join(' ') } } } end end context 'with valid JSON data but schema errors' do let(:user) { User.new(data: '{"city":"Quebec City"}') } specify do expect(user).not_to be_valid expect(user.errors.full_messages).to eql(['Data missing_keys country']) expect(user.data).to eql({ 'city' => 'Quebec City' }) expect(user.data_invalid_json).to be_nil end end context 'with invalid JSON data' do let(:data) { 'What? This is not JSON at all.' } let(:user) { User.new(data: data) } specify do expect(user.data_invalid_json).to eql(data) expect(user.data).to eql({}) end end end describe :schema do let(:validator) { JsonValidator.new(options) } let(:options) { { attributes: [:foo], schema: schema_option } } let(:schema) { validator.send(:schema, record) } context 'with String schema' do let(:schema_option) { double(:schema) } let(:record) { double(:record) } it { expect(schema).to eql(schema_option) } end context 'with Proc schema returning a Proc returning a Proc' do let(:schema_option) { -> { dynamic_schema } } let(:record) { record_class.new } let(:record_class) do Class.new do def dynamic_schema -> { another_dynamic_schema } end def another_dynamic_schema -> { what_another_dynamic_schema } end def what_another_dynamic_schema 'yay' end end end it { expect(schema).to eql('yay') } end context 'with Symbol schema' do let(:schema_option) { :dynamic_schema } let(:record) { record_class.new } let(:record_class) do Class.new do def dynamic_schema 'foo' end end end it { expect(schema).to eql('foo') } end end describe :message do let(:validator) { JsonValidator.new(options) } let(:options) { { attributes: [:foo], message: message_option } } let(:message) { validator.send(:message, errors) } let(:errors) { %i[first_error second_error] } context 'with Symbol message' do let(:message_option) { :invalid_json } it { expect(message).to eql([:invalid_json]) } end context 'with String value' do let(:message_option) { ->(errors) { errors } } it { expect(message).to eql(%i[first_error second_error]) } end end end # rubocop:enable Metrics/BlockLength
bsd-3-clause
Workday/OpenFrame
net/server/web_socket_encoder.cc
12653
// Copyright 2014 The Chromium 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 "net/server/web_socket_encoder.h" #include <vector> #include "base/logging.h" #include "base/strings/string_number_conversions.h" #include "base/strings/stringprintf.h" #include "net/base/io_buffer.h" #include "net/websockets/websocket_deflate_parameters.h" #include "net/websockets/websocket_extension.h" #include "net/websockets/websocket_extension_parser.h" namespace net { const char WebSocketEncoder::kClientExtensions[] = "Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits"; namespace { const int kInflaterChunkSize = 16 * 1024; // Constants for hybi-10 frame format. typedef int OpCode; const OpCode kOpCodeContinuation = 0x0; const OpCode kOpCodeText = 0x1; const OpCode kOpCodeBinary = 0x2; const OpCode kOpCodeClose = 0x8; const OpCode kOpCodePing = 0x9; const OpCode kOpCodePong = 0xA; const unsigned char kFinalBit = 0x80; const unsigned char kReserved1Bit = 0x40; const unsigned char kReserved2Bit = 0x20; const unsigned char kReserved3Bit = 0x10; const unsigned char kOpCodeMask = 0xF; const unsigned char kMaskBit = 0x80; const unsigned char kPayloadLengthMask = 0x7F; const size_t kMaxSingleBytePayloadLength = 125; const size_t kTwoBytePayloadLengthField = 126; const size_t kEightBytePayloadLengthField = 127; const size_t kMaskingKeyWidthInBytes = 4; WebSocket::ParseResult DecodeFrameHybi17(const base::StringPiece& frame, bool client_frame, int* bytes_consumed, std::string* output, bool* compressed) { size_t data_length = frame.length(); if (data_length < 2) return WebSocket::FRAME_INCOMPLETE; const char* buffer_begin = const_cast<char*>(frame.data()); const char* p = buffer_begin; const char* buffer_end = p + data_length; unsigned char first_byte = *p++; unsigned char second_byte = *p++; bool final = (first_byte & kFinalBit) != 0; bool reserved1 = (first_byte & kReserved1Bit) != 0; bool reserved2 = (first_byte & kReserved2Bit) != 0; bool reserved3 = (first_byte & kReserved3Bit) != 0; int op_code = first_byte & kOpCodeMask; bool masked = (second_byte & kMaskBit) != 0; *compressed = reserved1; if (!final || reserved2 || reserved3) return WebSocket::FRAME_ERROR; // Only compression extension is supported. bool closed = false; switch (op_code) { case kOpCodeClose: closed = true; break; case kOpCodeText: break; case kOpCodeBinary: // We don't support binary frames yet. case kOpCodeContinuation: // We don't support binary frames yet. case kOpCodePing: // We don't support binary frames yet. case kOpCodePong: // We don't support binary frames yet. default: return WebSocket::FRAME_ERROR; } if (client_frame && !masked) // In Hybi-17 spec client MUST mask its frame. return WebSocket::FRAME_ERROR; uint64 payload_length64 = second_byte & kPayloadLengthMask; if (payload_length64 > kMaxSingleBytePayloadLength) { int extended_payload_length_size; if (payload_length64 == kTwoBytePayloadLengthField) extended_payload_length_size = 2; else { DCHECK(payload_length64 == kEightBytePayloadLengthField); extended_payload_length_size = 8; } if (buffer_end - p < extended_payload_length_size) return WebSocket::FRAME_INCOMPLETE; payload_length64 = 0; for (int i = 0; i < extended_payload_length_size; ++i) { payload_length64 <<= 8; payload_length64 |= static_cast<unsigned char>(*p++); } } size_t actual_masking_key_length = masked ? kMaskingKeyWidthInBytes : 0; static const uint64 max_payload_length = 0x7FFFFFFFFFFFFFFFull; static size_t max_length = std::numeric_limits<size_t>::max(); if (payload_length64 > max_payload_length || payload_length64 + actual_masking_key_length > max_length) { // WebSocket frame length too large. return WebSocket::FRAME_ERROR; } size_t payload_length = static_cast<size_t>(payload_length64); size_t total_length = actual_masking_key_length + payload_length; if (static_cast<size_t>(buffer_end - p) < total_length) return WebSocket::FRAME_INCOMPLETE; if (masked) { output->resize(payload_length); const char* masking_key = p; char* payload = const_cast<char*>(p + kMaskingKeyWidthInBytes); for (size_t i = 0; i < payload_length; ++i) // Unmask the payload. (*output)[i] = payload[i] ^ masking_key[i % kMaskingKeyWidthInBytes]; } else { output->assign(p, p + payload_length); } size_t pos = p + actual_masking_key_length + payload_length - buffer_begin; *bytes_consumed = pos; return closed ? WebSocket::FRAME_CLOSE : WebSocket::FRAME_OK; } void EncodeFrameHybi17(const std::string& message, int masking_key, bool compressed, std::string* output) { std::vector<char> frame; OpCode op_code = kOpCodeText; size_t data_length = message.length(); int reserved1 = compressed ? kReserved1Bit : 0; frame.push_back(kFinalBit | op_code | reserved1); char mask_key_bit = masking_key != 0 ? kMaskBit : 0; if (data_length <= kMaxSingleBytePayloadLength) { frame.push_back(static_cast<char>(data_length) | mask_key_bit); } else if (data_length <= 0xFFFF) { frame.push_back(kTwoBytePayloadLengthField | mask_key_bit); frame.push_back((data_length & 0xFF00) >> 8); frame.push_back(data_length & 0xFF); } else { frame.push_back(kEightBytePayloadLengthField | mask_key_bit); char extended_payload_length[8]; size_t remaining = data_length; // Fill the length into extended_payload_length in the network byte order. for (int i = 0; i < 8; ++i) { extended_payload_length[7 - i] = remaining & 0xFF; remaining >>= 8; } frame.insert(frame.end(), extended_payload_length, extended_payload_length + 8); DCHECK(!remaining); } const char* data = const_cast<char*>(message.data()); if (masking_key != 0) { const char* mask_bytes = reinterpret_cast<char*>(&masking_key); frame.insert(frame.end(), mask_bytes, mask_bytes + 4); for (size_t i = 0; i < data_length; ++i) // Mask the payload. frame.push_back(data[i] ^ mask_bytes[i % kMaskingKeyWidthInBytes]); } else { frame.insert(frame.end(), data, data + data_length); } *output = std::string(&frame[0], frame.size()); } } // anonymous namespace // static scoped_ptr<WebSocketEncoder> WebSocketEncoder::CreateServer() { return make_scoped_ptr(new WebSocketEncoder(FOR_SERVER, nullptr, nullptr)); } // static scoped_ptr<WebSocketEncoder> WebSocketEncoder::CreateServer( const std::string& extensions, WebSocketDeflateParameters* deflate_parameters) { WebSocketExtensionParser parser; if (!parser.Parse(extensions)) { // Failed to parse Sec-WebSocket-Extensions header. We MUST fail the // connection. return nullptr; } for (const auto& extension : parser.extensions()) { std::string failure_message; WebSocketDeflateParameters offer; if (!offer.Initialize(extension, &failure_message) || !offer.IsValidAsRequest(&failure_message)) { // We decline unknown / malformed extensions. continue; } WebSocketDeflateParameters response = offer; if (offer.is_client_max_window_bits_specified() && !offer.has_client_max_window_bits_value()) { // We need to choose one value for the response. response.SetClientMaxWindowBits(15); } DCHECK(response.IsValidAsResponse()); DCHECK(offer.IsCompatibleWith(response)); auto deflater = make_scoped_ptr( new WebSocketDeflater(response.server_context_take_over_mode())); auto inflater = make_scoped_ptr( new WebSocketInflater(kInflaterChunkSize, kInflaterChunkSize)); if (!deflater->Initialize(response.PermissiveServerMaxWindowBits()) || !inflater->Initialize(response.PermissiveClientMaxWindowBits())) { // For some reason we cannot accept the parameters. continue; } *deflate_parameters = response; return make_scoped_ptr( new WebSocketEncoder(FOR_SERVER, deflater.Pass(), inflater.Pass())); } // We cannot find an acceptable offer. return make_scoped_ptr(new WebSocketEncoder(FOR_SERVER, nullptr, nullptr)); } // static scoped_ptr<WebSocketEncoder> WebSocketEncoder::CreateClient( const std::string& response_extensions) { // TODO(yhirano): Add a way to return an error. WebSocketExtensionParser parser; if (!parser.Parse(response_extensions)) { // Parse error. Note that there are two cases here. // 1) There is no Sec-WebSocket-Extensions header. // 2) There is a malformed Sec-WebSocketExtensions header. // We should return a deflate-disabled encoder for the former case and // fail the connection for the latter case. return make_scoped_ptr(new WebSocketEncoder(FOR_CLIENT, nullptr, nullptr)); } if (parser.extensions().size() != 1) { // Only permessage-deflate extension is supported. // TODO (yhirano): Fail the connection. return make_scoped_ptr(new WebSocketEncoder(FOR_CLIENT, nullptr, nullptr)); } const auto& extension = parser.extensions()[0]; WebSocketDeflateParameters params; std::string failure_message; if (!params.Initialize(extension, &failure_message) || !params.IsValidAsResponse(&failure_message)) { // TODO (yhirano): Fail the connection. return make_scoped_ptr(new WebSocketEncoder(FOR_CLIENT, nullptr, nullptr)); } auto deflater = make_scoped_ptr( new WebSocketDeflater(params.client_context_take_over_mode())); auto inflater = make_scoped_ptr( new WebSocketInflater(kInflaterChunkSize, kInflaterChunkSize)); if (!deflater->Initialize(params.PermissiveClientMaxWindowBits()) || !inflater->Initialize(params.PermissiveServerMaxWindowBits())) { // TODO (yhirano): Fail the connection. return make_scoped_ptr(new WebSocketEncoder(FOR_CLIENT, nullptr, nullptr)); } return make_scoped_ptr( new WebSocketEncoder(FOR_CLIENT, deflater.Pass(), inflater.Pass())); } WebSocketEncoder::WebSocketEncoder(Type type, scoped_ptr<WebSocketDeflater> deflater, scoped_ptr<WebSocketInflater> inflater) : type_(type), deflater_(deflater.Pass()), inflater_(inflater.Pass()) {} WebSocketEncoder::~WebSocketEncoder() {} WebSocket::ParseResult WebSocketEncoder::DecodeFrame( const base::StringPiece& frame, int* bytes_consumed, std::string* output) { bool compressed; WebSocket::ParseResult result = DecodeFrameHybi17( frame, type_ == FOR_SERVER, bytes_consumed, output, &compressed); if (result == WebSocket::FRAME_OK && compressed) { if (!Inflate(output)) result = WebSocket::FRAME_ERROR; } return result; } void WebSocketEncoder::EncodeFrame(const std::string& frame, int masking_key, std::string* output) { std::string compressed; if (Deflate(frame, &compressed)) EncodeFrameHybi17(compressed, masking_key, true, output); else EncodeFrameHybi17(frame, masking_key, false, output); } bool WebSocketEncoder::Inflate(std::string* message) { if (!inflater_) return false; if (!inflater_->AddBytes(message->data(), message->length())) return false; if (!inflater_->Finish()) return false; std::vector<char> output; while (inflater_->CurrentOutputSize() > 0) { scoped_refptr<IOBufferWithSize> chunk = inflater_->GetOutput(inflater_->CurrentOutputSize()); if (!chunk.get()) return false; output.insert(output.end(), chunk->data(), chunk->data() + chunk->size()); } *message = output.size() ? std::string(&output[0], output.size()) : std::string(); return true; } bool WebSocketEncoder::Deflate(const std::string& message, std::string* output) { if (!deflater_) return false; if (!deflater_->AddBytes(message.data(), message.length())) { deflater_->Finish(); return false; } if (!deflater_->Finish()) return false; scoped_refptr<IOBufferWithSize> buffer = deflater_->GetOutput(deflater_->CurrentOutputSize()); if (!buffer.get()) return false; *output = std::string(buffer->data(), buffer->size()); return true; } } // namespace net
bsd-3-clause
mgoffin/osquery
osquery/core/init.cpp
15563
/* * Copyright (c) 2014, Facebook, Inc. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * */ #include <chrono> #include <csignal> #include <random> #include <syslog.h> #include <stdio.h> #include <time.h> #include <unistd.h> #include <boost/algorithm/string/trim.hpp> #include <boost/filesystem.hpp> #include <osquery/config.h> #include <osquery/core.h> #include <osquery/events.h> #include <osquery/extensions.h> #include <osquery/flags.h> #include <osquery/filesystem.h> #include <osquery/logger.h> #include <osquery/registry.h> #include "osquery/core/watcher.h" #include "osquery/database/db_handle.h" #if defined(__linux__) || defined(__FreeBSD__) #include <sys/resource.h> #endif #ifdef __linux__ #include <sys/syscall.h> /* * These are the io priority groups as implemented by CFQ. RT is the realtime * class, it always gets premium service. BE is the best-effort scheduling * class, the default for any process. IDLE is the idle scheduling class, it * is only served when no one else is using the disk. */ enum { IOPRIO_CLASS_NONE, IOPRIO_CLASS_RT, IOPRIO_CLASS_BE, IOPRIO_CLASS_IDLE, }; /* * 8 best effort priority levels are supported */ #define IOPRIO_BE_NR (8) enum { IOPRIO_WHO_PROCESS = 1, IOPRIO_WHO_PGRP, IOPRIO_WHO_USER, }; #endif #define DESCRIPTION \ "osquery %s, your OS as a high-performance relational database\n" #define EPILOG "\nosquery project page <https://osquery.io>.\n" #define OPTIONS \ "\nosquery configuration options (set by config or CLI flags):\n\n" #define OPTIONS_SHELL "\nosquery shell-only CLI flags:\n\n" #define OPTIONS_CLI "osquery%s command line flags:\n\n" #define USAGE "Usage: %s [OPTION]... %s\n\n" #define CONFIG_ERROR \ "You are using default configurations for osqueryd for one or more of the " \ "following\n" \ "flags: pidfile, db_path.\n\n" \ "These options create files in /var/osquery but it looks like that path " \ "has not\n" \ "been created. Please consider explicitly defining those " \ "options as a different \n" \ "path. Additionally, review the \"using osqueryd\" wiki page:\n" \ " - https://osquery.readthedocs.org/en/latest/introduction/using-osqueryd/" \ "\n\n"; /// Seconds to alarm and quit for non-responsive event loops. #define SIGNAL_ALARM_TIMEOUT 4 namespace fs = boost::filesystem; namespace { extern "C" { static inline bool hasWorkerVariable() { return (getenv("OSQUERY_WORKER") != nullptr); } volatile std::sig_atomic_t kHandledSignal{0}; void signalHandler(int signal) { // Inform exit status of main threads blocked by service joins. if (kHandledSignal == 0) { kHandledSignal = signal; } // Handle signals based on a tri-state (worker, watcher, neither). pid_t worker_pid = osquery::Watcher::getWorker(); bool is_watcher = worker_pid > 0; if (signal == SIGHUP) { if (!is_watcher || hasWorkerVariable()) { // Reload configuration. } } else if (signal == SIGTERM || signal == SIGINT || signal == SIGABRT) { // Time to stop, set an upper bound time constraint on how long threads // have to terminate (join). Publishers may be in 20ms or similar sleeps. alarm(SIGNAL_ALARM_TIMEOUT); // Restore the default signal handler. std::signal(signal, SIG_DFL); // The watcher waits for the worker to die. if (is_watcher) { // Bind the fate of the worker to this watcher. osquery::Watcher::bindFates(); } else { // Otherwise the worker or non-watched process joins. osquery::EventFactory::end(true); // Re-raise the handled signal, which has since been restored to default. raise(signal); } } else if (signal == SIGALRM) { // Restore the default signal handler for SIGALRM. std::signal(SIGALRM, SIG_DFL); // Took too long to stop. VLOG(1) << "Cannot stop event publisher threads"; raise((kHandledSignal != 0) ? kHandledSignal : SIGALRM); } if (is_watcher) { // The signal should be proliferated through the process group. // Otherwise the watcher could 'forward' the signal to workers and // managed extension processes. } } } } namespace osquery { using chrono_clock = std::chrono::high_resolution_clock; #ifndef __APPLE__ CLI_FLAG(bool, daemonize, false, "Run as daemon (osqueryd only)"); #endif DECLARE_string(distributed_plugin); DECLARE_bool(disable_distributed); DECLARE_string(config_plugin); DECLARE_bool(config_check); DECLARE_bool(database_dump); ToolType kToolType = OSQUERY_TOOL_UNKNOWN; void printUsage(const std::string& binary, int tool) { // Parse help options before gflags. Only display osquery-related options. fprintf(stdout, DESCRIPTION, kVersion.c_str()); if (tool == OSQUERY_TOOL_SHELL) { // The shell allows a caller to run a single SQL statement and exit. fprintf(stdout, USAGE, binary.c_str(), "[SQL STATEMENT]"); } else { fprintf(stdout, USAGE, binary.c_str(), ""); } if (tool == OSQUERY_EXTENSION) { fprintf(stdout, OPTIONS_CLI, " extension"); Flag::printFlags(false, true); } else { fprintf(stdout, OPTIONS_CLI, ""); Flag::printFlags(false, false, true); fprintf(stdout, OPTIONS); Flag::printFlags(); } if (tool == OSQUERY_TOOL_SHELL) { // Print shell flags. fprintf(stdout, OPTIONS_SHELL); Flag::printFlags(true); } fprintf(stdout, EPILOG); } Initializer::Initializer(int& argc, char**& argv, ToolType tool) : argc_(&argc), argv_(&argv), tool_(tool), binary_((tool == OSQUERY_TOOL_DAEMON) ? "osqueryd" : "osqueryi") { std::srand(chrono_clock::now().time_since_epoch().count()); // Handled boost filesystem locale problems fixes in 1.56. // See issue #1559 for the discussion and upstream boost patch. try { boost::filesystem::path::codecvt(); } catch (const std::runtime_error& e) { setenv("LC_ALL", "C", 1); } // osquery implements a custom help/usage output. for (int i = 1; i < *argc_; i++) { auto help = std::string((*argv_)[i]); if ((help == "--help" || help == "-help" || help == "--h" || help == "-h") && tool != OSQUERY_TOOL_TEST) { printUsage(binary_, tool_); ::exit(0); } } // To change the default config plugin, compile osquery with // -DOSQUERY_DEFAULT_CONFIG_PLUGIN=<new_default_plugin> #ifdef OSQUERY_DEFAULT_CONFIG_PLUGIN FLAGS_config_plugin = STR(OSQUERY_DEFAULT_CONFIG_PLUGIN); #endif // To change the default logger plugin, compile osquery with // -DOSQUERY_DEFAULT_LOGGER_PLUGIN=<new_default_plugin> #ifdef OSQUERY_DEFAULT_LOGGER_PLUGIN FLAGS_logger_plugin = STR(OSQUERY_DEFAULT_LOGGER_PLUGIN); #endif // Set version string from CMake build GFLAGS_NAMESPACE::SetVersionString(kVersion.c_str()); // Let gflags parse the non-help options/flags. GFLAGS_NAMESPACE::ParseCommandLineFlags( argc_, argv_, (tool == OSQUERY_TOOL_SHELL)); // Set the tool type to allow runtime decisions based on daemon, shell, etc. kToolType = tool; if (tool == OSQUERY_TOOL_SHELL) { // The shell is transient, rewrite config-loaded paths. FLAGS_disable_logging = true; // Get the caller's home dir for temporary storage/state management. auto homedir = osqueryHomeDirectory(); if (osquery::pathExists(homedir).ok() || boost::filesystem::create_directory(homedir)) { // Only apply user/shell-specific paths if not overridden by CLI flag. if (Flag::isDefault("database_path")) { osquery::FLAGS_database_path = homedir + "/shell.db"; } if (Flag::isDefault("extensions_socket")) { osquery::FLAGS_extensions_socket = homedir + "/shell.em"; } } } // All tools handle the same set of signals. // If a daemon process is a watchdog the signal is passed to the worker, // unless the worker has not yet started. std::signal(SIGTERM, signalHandler); std::signal(SIGABRT, signalHandler); std::signal(SIGINT, signalHandler); std::signal(SIGHUP, signalHandler); std::signal(SIGALRM, signalHandler); // If the caller is checking configuration, disable the watchdog/worker. if (FLAGS_config_check) { FLAGS_disable_watchdog = true; } // Initialize the status and results logger. initStatusLogger(binary_); if (tool != OSQUERY_EXTENSION) { if (isWorker()) { VLOG(1) << "osquery worker initialized [watcher=" << getppid() << "]"; } else { VLOG(1) << "osquery initialized [version=" << kVersion << "]"; } } else { VLOG(1) << "osquery extension initialized [sdk=" << kSDKVersion << "]"; } } void Initializer::initDaemon() { if (FLAGS_config_check) { // No need to daemonize, emit log lines, or create process mutexes. return; } #ifndef __APPLE__ // OS X uses launchd to daemonize. if (osquery::FLAGS_daemonize) { if (daemon(0, 0) == -1) { ::exit(EXIT_FAILURE); } } #endif // Print the version to SYSLOG. syslog( LOG_NOTICE, "%s started [version=%s]", binary_.c_str(), kVersion.c_str()); // Check if /var/osquery exists if ((Flag::isDefault("pidfile") || Flag::isDefault("database_path")) && !isDirectory("/var/osquery")) { std::cerr << CONFIG_ERROR; } // Create a process mutex around the daemon. auto pid_status = createPidFile(); if (!pid_status.ok()) { LOG(ERROR) << binary_ << " initialize failed: " << pid_status.toString(); ::exit(EXIT_FAILURE); } // Nice ourselves if using a watchdog and the level is not too permissive. if (!FLAGS_disable_watchdog && FLAGS_watchdog_level >= WATCHDOG_LEVEL_DEFAULT && FLAGS_watchdog_level != WATCHDOG_LEVEL_DEBUG) { // Set CPU scheduling I/O limits. setpriority(PRIO_PGRP, 0, 10); #ifdef __linux__ // Using: ioprio_set(IOPRIO_WHO_PGRP, 0, IOPRIO_CLASS_IDLE); syscall(SYS_ioprio_set, IOPRIO_WHO_PGRP, 0, IOPRIO_CLASS_IDLE); #elif defined(__APPLE__) setiopolicy_np(IOPOL_TYPE_DISK, IOPOL_SCOPE_PROCESS, IOPOL_THROTTLE); #endif } } void Initializer::initWatcher() { // The watcher takes a list of paths to autoload extensions from. osquery::loadExtensions(); // Add a watcher service thread to start/watch an optional worker and set // of optional extensions in the autoload paths. if (Watcher::hasManagedExtensions() || !FLAGS_disable_watchdog) { Dispatcher::addService(std::make_shared<WatcherRunner>( *argc_, *argv_, !FLAGS_disable_watchdog)); } // If there are no autoloaded extensions, the watcher service will end, // otherwise it will continue as a background thread and respawn them. // If the watcher is also a worker watchdog it will do nothing but monitor // the extensions and worker process. if (!FLAGS_disable_watchdog) { Dispatcher::joinServices(); // Execution should only reach this point if a signal was handled by the // worker and watcher. ::exit((kHandledSignal > 0) ? 128 + kHandledSignal : EXIT_FAILURE); } } void Initializer::initWorker(const std::string& name) { // Clear worker's arguments. size_t name_size = strlen((*argv_)[0]); auto original_name = std::string((*argv_)[0]); for (int i = 0; i < *argc_; i++) { if ((*argv_)[i] != nullptr) { memset((*argv_)[i], ' ', strlen((*argv_)[i])); } } // Set the worker's process name. if (name.size() < name_size) { std::copy(name.begin(), name.end(), (*argv_)[0]); (*argv_)[0][name.size()] = '\0'; } else { std::copy(original_name.begin(), original_name.end(), (*argv_)[0]); (*argv_)[0][original_name.size()] = '\0'; } // Start a watcher watcher thread to exit the process if the watcher exits. Dispatcher::addService(std::make_shared<WatcherWatcherRunner>(getppid())); } void Initializer::initWorkerWatcher(const std::string& name) { if (isWorker()) { initWorker(name); } else { // The watcher will forever monitor and spawn additional workers. initWatcher(); } } bool Initializer::isWorker() { return hasWorkerVariable(); } void Initializer::initActivePlugin(const std::string& type, const std::string& name) { // Use a delay, meaning the amount of milliseconds waited for extensions. size_t delay = 0; // The timeout is the maximum microseconds in seconds to wait for extensions. size_t timeout = atoi(FLAGS_extensions_timeout.c_str()) * 1000000; if (timeout < kExtensionInitializeLatencyUS * 10) { timeout = kExtensionInitializeLatencyUS * 10; } while (!Registry::setActive(type, name)) { if (!Watcher::hasManagedExtensions() || delay > timeout) { LOG(ERROR) << "Active " << type << " plugin not found: " << name; ::exit(EXIT_CATASTROPHIC); } delay += kExtensionInitializeLatencyUS; ::usleep(kExtensionInitializeLatencyUS); } } void Initializer::start() { // Load registry/extension modules before extensions. osquery::loadModules(); // Pre-extension manager initialization options checking. if (FLAGS_config_check && !Watcher::hasManagedExtensions()) { FLAGS_disable_extensions = true; } // A daemon must always have R/W access to the database. DBHandle::setAllowOpen(true); DBHandle::setRequireWrite(tool_ == OSQUERY_TOOL_DAEMON); if (!DBHandle::checkDB()) { LOG(ERROR) << RLOG(1629) << binary_ << " initialize failed: Could not open RocksDB"; if (isWorker()) { ::exit(EXIT_CATASTROPHIC); } else { ::exit(EXIT_FAILURE); } } // Bind to an extensions socket and wait for registry additions. osquery::startExtensionManager(); // Then set the config plugin, which uses a single/active plugin. initActivePlugin("config", FLAGS_config_plugin); // Run the setup for all lazy registries (tables, SQL). Registry::setUp(); if (FLAGS_config_check) { // The initiator requested an initialization and config check. auto s = Config::getInstance().load(); if (!s.ok()) { std::cerr << "Error reading config: " << s.toString() << "\n"; } // A configuration check exits the application. ::exit(s.getCode()); } if (FLAGS_database_dump) { dumpDatabase(); ::exit(EXIT_SUCCESS); } // Load the osquery config using the default/active config plugin. auto s = Config::getInstance().load(); if (!s.ok()) { auto message = "Error reading config: " + s.toString(); if (tool_ == OSQUERY_TOOL_DAEMON) { LOG(WARNING) << message; } else { LOG(INFO) << message; } } // Initialize the status and result plugin logger. initActivePlugin("logger", FLAGS_logger_plugin); initLogger(binary_); // Initialize the distributed plugin, if necessary if (!FLAGS_disable_distributed) { if (Registry::exists("distributed", FLAGS_distributed_plugin)) { initActivePlugin("distributed", FLAGS_distributed_plugin); } } // Start event threads. osquery::attachEvents(); EventFactory::delay(); } void Initializer::shutdown() { // End any event type run loops. EventFactory::end(); // Hopefully release memory used by global string constructors in gflags. GFLAGS_NAMESPACE::ShutDownCommandLineFlags(); } }
bsd-3-clause
endlessm/chromium-browser
chrome/android/java/src/org/chromium/chrome/browser/offlinepages/prefetch/PrefetchPrefs.java
3959
// Copyright 2017 The Chromium 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 org.chromium.chrome.browser.offlinepages.prefetch; import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.SharedPreferencesManager; /** * Preferences used to provide prefetch related notifications. * - Having new pages: boolean indicating whether new pages have been saved or not * - Notification timestamp: the last time a notification is shown * - Offline counter: how many times the task ran and seen that we are offline * - Ignored notification counter: how many times in a row we showed a notification without user * reacting to it */ public class PrefetchPrefs { /** * Sets the flag to tell whether prefetch notifications are enabled in user settings. */ public static void setNotificationEnabled(boolean enabled) { SharedPreferencesManager.getInstance().writeBoolean( ChromePreferenceKeys.PREFETCH_NOTIFICATION_ENABLED, enabled); } /** * Returns the flag to tell whether prefetch notifications are enabled in user settings. */ public static boolean getNotificationEnabled() { return SharedPreferencesManager.getInstance().readBoolean( ChromePreferenceKeys.PREFETCH_NOTIFICATION_ENABLED, true); } /** * Sets the flag to tell whether new pages have been saved. */ public static void setHasNewPages(boolean hasNewPages) { SharedPreferencesManager.getInstance().writeBoolean( ChromePreferenceKeys.PREFETCH_HAS_NEW_PAGES, hasNewPages); } /** * Returns the flag to tell whether new pages have been saved. */ public static boolean getHasNewPages() { return SharedPreferencesManager.getInstance().readBoolean( ChromePreferenceKeys.PREFETCH_HAS_NEW_PAGES, false); } /** * Sets the last time a notification is shown, in milliseconds since the epoch. */ public static void setNotificationLastShownTime(long timeInMillis) { SharedPreferencesManager.getInstance().writeLong( ChromePreferenceKeys.PREFETCH_NOTIFICATION_TIME, timeInMillis); } /** * Returns the last time a notification is shown, in milliseconds since the epoch. */ public static long getNotificationLastShownTime() { return SharedPreferencesManager.getInstance().readLong( ChromePreferenceKeys.PREFETCH_NOTIFICATION_TIME); } /** * Sets the offline counter. */ public static void setOfflineCounter(int counter) { SharedPreferencesManager.getInstance().writeInt( ChromePreferenceKeys.PREFETCH_OFFLINE_COUNTER, counter); } /** * Increments and returns the offline counter. */ public static int incrementOfflineCounter() { return SharedPreferencesManager.getInstance().incrementInt( ChromePreferenceKeys.PREFETCH_OFFLINE_COUNTER); } /** * Sets the ignored notification counter. */ public static void setIgnoredNotificationCounter(int counter) { SharedPreferencesManager.getInstance().writeInt( ChromePreferenceKeys.PREFETCH_IGNORED_NOTIFICATION_COUNTER, counter); } /** * Returns the ignored notification counter. */ public static int getIgnoredNotificationCounter() { return SharedPreferencesManager.getInstance().readInt( ChromePreferenceKeys.PREFETCH_IGNORED_NOTIFICATION_COUNTER); } /** * Increments and returns the ignored notification counter. */ public static int incrementIgnoredNotificationCounter() { return SharedPreferencesManager.getInstance().incrementInt( ChromePreferenceKeys.PREFETCH_IGNORED_NOTIFICATION_COUNTER); } }
bsd-3-clause
PowerOfCode/Eto
Source/Eto.iOS/Forms/Controls/NumericUpDownHandler.cs
1650
using System; using System.Reflection; using SD = System.Drawing; using Eto.Forms; using UIKit; using Eto.Drawing; namespace Eto.iOS.Forms.Controls { public class NumericUpDownHandler : IosControl<UITextField, NumericUpDown, NumericUpDown.ICallback>, NumericUpDown.IHandler { public NumericUpDownHandler() { Control = new UITextField(); } protected override SizeF GetNaturalSize(SizeF availableSize) { return SizeF.Max(base.GetNaturalSize(availableSize), new SizeF(60, 0)); } protected override void Initialize() { base.Initialize(); Control.KeyboardType = UIKeyboardType.NumberPad; Control.ReturnKeyType = UIReturnKeyType.Done; Control.BorderStyle = UITextBorderStyle.RoundedRect; Control.ShouldReturn = (textField) => { textField.ResignFirstResponder(); return true; }; Control.EditingChanged += (sender, e) => Callback.OnValueChanged(Widget, EventArgs.Empty); } public bool ReadOnly { get; set; } public double Value { get { double value; if (double.TryParse(Control.Text, out value)) return value; return 0; } set { Control.Text = value.ToString(); } } public double MinValue { get; set; } public double MaxValue { get; set; } public override Font Font { get { return base.Font; } set { base.Font = value; Control.Font = value.ToUI(); } } public double Increment { get; set; } public int DecimalPlaces { get; set; } public Color TextColor { get { return Control.TextColor.ToEto(); } set { Control.TextColor = value.ToNSUI(); } } } }
bsd-3-clause
yjhu/wowewe
models/ClientWechatFanSearch.php
3139
<?php namespace app\models; class ClientWechatFanSearch extends \yii\base\Model { public $nickname; public $mobile; public $carrier; public $province; public $city; public $create_time_start; public $create_time_end; public $gh_id; public $office_id; public $scene_pid; public $searchStr; public $page; public function rules() { return [ [[ 'gh_id', 'nickname', 'mobile', 'carrier', 'province', 'city', 'create_time_start', 'create_time_end', 'office_id', 'searchStr', 'scene_pid','page', ], 'safe'], ]; } public function search($params) { $query = \app\models\MUser::find() ->join('INNER JOIN', 'wx_openid_bind_mobile', 'wx_openid_bind_mobile.gh_id = wx_user.gh_id and wx_openid_bind_mobile.openid = wx_user.openid') ->where(['wx_user.subscribe' => 1]) ->orderBy(['wx_user.create_time' => SORT_DESC]); $dataProvider = new \yii\data\ActiveDataProvider([ 'query' => $query, 'pagination' => [ 'pageSize' => 10, ], ]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } if (!empty($this->page)) { $dataProvider->pagination->page = $this->page; } if (!empty($this->searchStr)) { $query->andWhere([ 'or', ['like', 'wx_user.nickname', $this->searchStr], ['like', 'wx_openid_bind_mobile.mobile', $this->searchStr], ]); } $this->addCondition($query, 'nickname', true); if (!empty($this->gh_id)) { $query->andWhere(['wx_user.gh_id' => $this->gh_id]); } if (!empty($this->office_id)) { $query->andWhere(['wx_user.belongto' => $this->office_id]); } $query->andFilterWhere(['like', 'wx_openid_bind_mobile.mobile', $this->mobile]); if (trim($this->create_time_start) !== '') { $query->andWhere('date(wx_user.create_time)>=:create_time', [':create_time' => $this->create_time_start]); } if (trim($this->create_time_end) !== '') { $query->andWhere('date(wx_user.create_time)<=:create_time_2', [':create_time_2' => $this->create_time_end]); } return $dataProvider; } protected function addCondition($query, $attribute, $partialMatch = false) { if (($pos = strrpos($attribute, '.')) !== false) { $modelAttribute = substr($attribute, $pos + 1); } else { $modelAttribute = $attribute; } $value = $this->$modelAttribute; if (trim($value) === '') { return; } if ($partialMatch) { $query->andWhere(['like', $attribute, $value]); } else { $query->andWhere([$attribute => $value]); } } }
bsd-3-clause
notaz/ia32rtools
run_idac_adj.sh
285
#!/bin/sh -x set -e f=/tmp/sedcmd_ echo -n "sed -i '\ s:__cdecl: /*__cdecl*/:;\ s:__stdcall: /*__stdcall*/:;\ s:__usercall: /*__usercall*/:;\ s:__userpurge: /*__userpurge*/:;\ s:__thiscall: /*__thiscall*/:;\ s:__fastcall: /*__fastcall*/:;\ s:\(<[^<> ]*>\):/*\1*/:g;\ ' $1" > $f . $f
bsd-3-clause
jetsgit/spree_promotion_tax
README.md
306
SpreePromotionTax ============= Calculator to correctly deduct a flat percent promotion from a sale before charging the tax. Shipping is taxed. This calculator was designed to work in conjunction with the SpreeTaxCloud gem Copyright (c) 2013 Jerrold Thompson, released under the New BSD License
bsd-3-clause
ineps/inesa
inesa/protected/controllers/AccesoController.php
5110
<?php class AccesoController extends Controller { /** * @var string the default layout for the views. Defaults to '//layouts/column2', meaning * using two-column layout. See 'protected/views/layouts/column2.php'. */ public $layout='//layouts/column2'; /** * @return array action filters */ public function filters() { return array( 'accessControl', // perform access control for CRUD operations 'postOnly + delete', // we only allow deletion via POST request ); } /** * Specifies the access control rules. * This method is used by the 'accessControl' filter. * @return array access control rules */ public function accessRules() { return array( array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=>array('index','view', 'vistaempresas','create', 'admin', 'update'), 'expression'=>'!$user->isGuest && Yii::app()->user->getState("nivel_acceso") == "Gerente"', ), array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=>array('index', 'vistaempresas','create', 'admin', 'view'), 'expression'=>'!$user->isGuest && Yii::app()->user->getState("nivel_acceso") == "Ventas"', ), array('allow', // allow all users to perform 'index' and 'view' actions 'actions'=>array('index', 'admin', 'update', 'view', 'create', 'vistaempresas'), 'expression'=>'!$user->isGuest && Yii::app()->user->getState("persona") == "administrador"', ), /*array('allow', // allow authenticated user to perform 'create' and 'update' actions 'actions'=>array('create','update'), 'users'=>array('@'), ), array('allow', // allow admin user to perform 'admin' and 'delete' actions 'actions'=>array('admin','delete', 'vistaempresas'), 'users'=>array('admin'), ),*/ array('deny', // deny all users 'users'=>array('*'), ), ); } /** * Displays a particular model. * @param integer $id the ID of the model to be displayed */ public function actionView($id) { $this->render('view',array( 'model'=>$this->loadModel($id), )); } /** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($id) { $model=new Acceso; // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Acceso'])) { $model->attributes=$_POST['Acceso']; if($model->save()) $this->redirect(array('personas/admin','id'=>$id)); } $this->render('create',array( 'model'=>$model, 'id'=>$id, )); } /** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $model=$this->loadModel($id); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if(isset($_POST['Acceso'])) { $model->attributes=$_POST['Acceso']; if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('update',array( 'model'=>$model, )); } /** * Deletes a particular model. * If deletion is successful, the browser will be redirected to the 'admin' page. * @param integer $id the ID of the model to be deleted */ public function actionDelete($id) { $this->loadModel($id)->delete(); // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser if(!isset($_GET['ajax'])) $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin')); } /** * Lists all models. */ public function actionIndex() { $dataProvider=new CActiveDataProvider('Acceso'); $this->render('index',array( 'dataProvider'=>$dataProvider, )); } /** * Manages all models. */ public function actionAdmin() { $model=new Acceso('search'); $model->unsetAttributes(); // clear any default values if(isset($_GET['Acceso'])) $model->attributes=$_GET['Acceso']; $this->render('admin',array( 'model'=>$model, )); } /** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Acceso the loaded model * @throws CHttpException */ public function loadModel($id) { $model=Acceso::model()->findByPk($id); if($model===null) throw new CHttpException(404,'The requested page does not exist.'); return $model; } /** * Performs the AJAX validation. * @param Acceso $model the model to be validated */ protected function performAjaxValidation($model) { if(isset($_POST['ajax']) && $_POST['ajax']==='acceso-form') { echo CActiveForm::validate($model); Yii::app()->end(); } } }
bsd-3-clause
softak/webfaction_demo
apps/friends/templates/friends/search.j.html
1135
{% extends "friends/list_base.j.html" %} {% import "forms.j.macro" as forms %} {% import "friendship_controls.j.macro" as friendship_controls %} {% set friends_nav_active='search' %} {% set list = user_list %} {% block friends_content %} <section> <form id="friend-search-form" action="" method="post"> {{ csrf() }} {{ form.query }} <input type="submit" value="{{ _('Search') }}" class="btn default" /> </form> </section> {% if request.method == 'POST' and not form.errors %} <section> <h2>Results</h2> </section> {{ super() }} {% endif %} {% endblock %} {% block controls %} {% import "friendship_controls.j.macro" as friendship_controls %} {{ friendship_controls.friendship_controls(user, friend) }} {% endblock %} {% block empty_list %} {{ _('No matches.') }} {% endblock %} <script> {% block js_ready %} $('.card:nth-child(odd)').css('clear', 'left'); // TODO remove! $('a.ajaxy').click(function() { var $a = $(this); $.get($a.attr('href'), function(data) { $a.parent().html(data.message); }); return false; }); {% endblock %} </script>
bsd-3-clause
lsa-pucrs/jason-ros-releases
Jason-1.4.0a/doc/api/jason/mas2j/package-summary.html
6023
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- NewPage --> <html lang="en"> <head> <!-- Generated by javadoc (version 1.7.0_21) on Thu Dec 12 11:16:51 BRST 2013 --> <title>jason.mas2j (Jason - AgentSpeak Java Interpreter)</title> <meta name="date" content="2013-12-12"> <link rel="stylesheet" type="text/css" href="../../stylesheet.css" title="Style"> </head> <body> <script type="text/javascript"><!-- if (location.href.indexOf('is-external=true') == -1) { parent.document.title="jason.mas2j (Jason - AgentSpeak Java Interpreter)"; } //--> </script> <noscript> <div>JavaScript is disabled on your browser.</div> </noscript> <!-- ========= START OF TOP NAVBAR ======= --> <div class="topNav"><a name="navbar_top"> <!-- --> </a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../overview-summary.html">Overview</a></li> <li class="navBarCell1Rev">Package</li> <li>Class</li> <li><a href="package-use.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../deprecated-list.html">Deprecated</a></li> <li><a href="../../index-all.html">Index</a></li> <li><a href="../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../jason/jeditplugin/package-summary.html">Prev Package</a></li> <li><a href="../../jason/profiling/package-summary.html">Next Package</a></li> </ul> <ul class="navList"> <li><a href="../../index.html?jason/mas2j/package-summary.html" target="_top">Frames</a></li> <li><a href="package-summary.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_top"> <li><a href="../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_top"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_top"> <!-- --> </a></div> <!-- ========= END OF TOP NAVBAR ========= --> <div class="header"> <h1 title="Package" class="title">Package&nbsp;jason.mas2j</h1> <map id="G" name="G"> <area shape="rect" id="node1_0" href="./MAS2JProject.html" title="jason.mas2j.MAS2JProject" alt="" coords="16,17,117,42"/> <area shape="rect" id="node1" href="./MAS2JProject.html" title="&lt;TABLE&gt;" alt="" coords="5,5,128,53"/> <area shape="rect" id="node2_1" href="./ClassParameters.html" title="jason.mas2j.ClassParameters" alt="" coords="163,17,283,42"/> <area shape="rect" id="node2" href="./ClassParameters.html" title="&lt;TABLE&gt;" alt="" coords="152,5,293,53"/> <area shape="rect" id="node3_2" href="./AgentParameters.html" title="jason.mas2j.AgentParameters" alt="" coords="329,17,447,42"/> <area shape="rect" id="node3" href="./AgentParameters.html" title="&lt;TABLE&gt;" alt="" coords="318,5,458,53"/> </map> <!-- UML diagram added by UMLGraph version R5_6_6-1-g9240c4 (http://www.umlgraph.org/) --> <div align="center"><img src="jason.mas2j.png" alt="Package class diagram package jason.mas2j" usemap="#G" border=0/></div> </div> <div class="contentContainer"> <ul class="blockList"> <li class="blockList"> <table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation"> <caption><span>Class Summary</span><span class="tabEnd">&nbsp;</span></caption> <tr> <th class="colFirst" scope="col">Class</th> <th class="colLast" scope="col">Description</th> </tr> <tbody> <tr class="altColor"> <td class="colFirst"><a href="../../jason/mas2j/AgentParameters.html" title="class in jason.mas2j">AgentParameters</a></td> <td class="colLast"> <div class="block">represents the agent declaration in the MAS2J project file.</div> </td> </tr> <tr class="rowColor"> <td class="colFirst"><a href="../../jason/mas2j/ClassParameters.html" title="class in jason.mas2j">ClassParameters</a></td> <td class="colLast"> <div class="block">Used to store class parameters in .mas2j file, e.g.</div> </td> </tr> <tr class="altColor"> <td class="colFirst"><a href="../../jason/mas2j/MAS2JProject.html" title="class in jason.mas2j">MAS2JProject</a></td> <td class="colLast"> <div class="block">Represents a MAS2J project (usually created from a .mas2j file)</div> </td> </tr> </tbody> </table> </li> </ul> </div> <!-- ======= START OF BOTTOM NAVBAR ====== --> <div class="bottomNav"><a name="navbar_bottom"> <!-- --> </a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="navbar_bottom_firstrow"> <!-- --> </a> <ul class="navList" title="Navigation"> <li><a href="../../overview-summary.html">Overview</a></li> <li class="navBarCell1Rev">Package</li> <li>Class</li> <li><a href="package-use.html">Use</a></li> <li><a href="package-tree.html">Tree</a></li> <li><a href="../../deprecated-list.html">Deprecated</a></li> <li><a href="../../index-all.html">Index</a></li> <li><a href="../../help-doc.html">Help</a></li> </ul> </div> <div class="subNav"> <ul class="navList"> <li><a href="../../jason/jeditplugin/package-summary.html">Prev Package</a></li> <li><a href="../../jason/profiling/package-summary.html">Next Package</a></li> </ul> <ul class="navList"> <li><a href="../../index.html?jason/mas2j/package-summary.html" target="_top">Frames</a></li> <li><a href="package-summary.html" target="_top">No Frames</a></li> </ul> <ul class="navList" id="allclasses_navbar_bottom"> <li><a href="../../allclasses-noframe.html">All Classes</a></li> </ul> <div> <script type="text/javascript"><!-- allClassesLink = document.getElementById("allclasses_navbar_bottom"); if(window==top) { allClassesLink.style.display = "block"; } else { allClassesLink.style.display = "none"; } //--> </script> </div> <a name="skip-navbar_bottom"> <!-- --> </a></div> <!-- ======== END OF BOTTOM NAVBAR ======= --> </body> </html>
bsd-3-clause
akutz/go
src/cmd/compile/internal/ssa/rewritegeneric.go
597533
// Code generated from gen/generic.rules; DO NOT EDIT. // generated with: cd gen; go run *.go package ssa import "math" import "cmd/compile/internal/types" func rewriteValuegeneric(v *Value) bool { switch v.Op { case OpAdd16: return rewriteValuegeneric_OpAdd16(v) case OpAdd32: return rewriteValuegeneric_OpAdd32(v) case OpAdd32F: return rewriteValuegeneric_OpAdd32F(v) case OpAdd64: return rewriteValuegeneric_OpAdd64(v) case OpAdd64F: return rewriteValuegeneric_OpAdd64F(v) case OpAdd8: return rewriteValuegeneric_OpAdd8(v) case OpAddPtr: return rewriteValuegeneric_OpAddPtr(v) case OpAnd16: return rewriteValuegeneric_OpAnd16(v) case OpAnd32: return rewriteValuegeneric_OpAnd32(v) case OpAnd64: return rewriteValuegeneric_OpAnd64(v) case OpAnd8: return rewriteValuegeneric_OpAnd8(v) case OpAndB: return rewriteValuegeneric_OpAndB(v) case OpArraySelect: return rewriteValuegeneric_OpArraySelect(v) case OpCom16: return rewriteValuegeneric_OpCom16(v) case OpCom32: return rewriteValuegeneric_OpCom32(v) case OpCom64: return rewriteValuegeneric_OpCom64(v) case OpCom8: return rewriteValuegeneric_OpCom8(v) case OpConstInterface: return rewriteValuegeneric_OpConstInterface(v) case OpConstSlice: return rewriteValuegeneric_OpConstSlice(v) case OpConstString: return rewriteValuegeneric_OpConstString(v) case OpConvert: return rewriteValuegeneric_OpConvert(v) case OpCtz16: return rewriteValuegeneric_OpCtz16(v) case OpCtz32: return rewriteValuegeneric_OpCtz32(v) case OpCtz64: return rewriteValuegeneric_OpCtz64(v) case OpCtz8: return rewriteValuegeneric_OpCtz8(v) case OpCvt32Fto32: return rewriteValuegeneric_OpCvt32Fto32(v) case OpCvt32Fto64: return rewriteValuegeneric_OpCvt32Fto64(v) case OpCvt32Fto64F: return rewriteValuegeneric_OpCvt32Fto64F(v) case OpCvt32to32F: return rewriteValuegeneric_OpCvt32to32F(v) case OpCvt32to64F: return rewriteValuegeneric_OpCvt32to64F(v) case OpCvt64Fto32: return rewriteValuegeneric_OpCvt64Fto32(v) case OpCvt64Fto32F: return rewriteValuegeneric_OpCvt64Fto32F(v) case OpCvt64Fto64: return rewriteValuegeneric_OpCvt64Fto64(v) case OpCvt64to32F: return rewriteValuegeneric_OpCvt64to32F(v) case OpCvt64to64F: return rewriteValuegeneric_OpCvt64to64F(v) case OpCvtBoolToUint8: return rewriteValuegeneric_OpCvtBoolToUint8(v) case OpDiv16: return rewriteValuegeneric_OpDiv16(v) case OpDiv16u: return rewriteValuegeneric_OpDiv16u(v) case OpDiv32: return rewriteValuegeneric_OpDiv32(v) case OpDiv32F: return rewriteValuegeneric_OpDiv32F(v) case OpDiv32u: return rewriteValuegeneric_OpDiv32u(v) case OpDiv64: return rewriteValuegeneric_OpDiv64(v) case OpDiv64F: return rewriteValuegeneric_OpDiv64F(v) case OpDiv64u: return rewriteValuegeneric_OpDiv64u(v) case OpDiv8: return rewriteValuegeneric_OpDiv8(v) case OpDiv8u: return rewriteValuegeneric_OpDiv8u(v) case OpEq16: return rewriteValuegeneric_OpEq16(v) case OpEq32: return rewriteValuegeneric_OpEq32(v) case OpEq32F: return rewriteValuegeneric_OpEq32F(v) case OpEq64: return rewriteValuegeneric_OpEq64(v) case OpEq64F: return rewriteValuegeneric_OpEq64F(v) case OpEq8: return rewriteValuegeneric_OpEq8(v) case OpEqB: return rewriteValuegeneric_OpEqB(v) case OpEqInter: return rewriteValuegeneric_OpEqInter(v) case OpEqPtr: return rewriteValuegeneric_OpEqPtr(v) case OpEqSlice: return rewriteValuegeneric_OpEqSlice(v) case OpIMake: return rewriteValuegeneric_OpIMake(v) case OpInterCall: return rewriteValuegeneric_OpInterCall(v) case OpIsInBounds: return rewriteValuegeneric_OpIsInBounds(v) case OpIsNonNil: return rewriteValuegeneric_OpIsNonNil(v) case OpIsSliceInBounds: return rewriteValuegeneric_OpIsSliceInBounds(v) case OpLeq16: return rewriteValuegeneric_OpLeq16(v) case OpLeq16U: return rewriteValuegeneric_OpLeq16U(v) case OpLeq32: return rewriteValuegeneric_OpLeq32(v) case OpLeq32F: return rewriteValuegeneric_OpLeq32F(v) case OpLeq32U: return rewriteValuegeneric_OpLeq32U(v) case OpLeq64: return rewriteValuegeneric_OpLeq64(v) case OpLeq64F: return rewriteValuegeneric_OpLeq64F(v) case OpLeq64U: return rewriteValuegeneric_OpLeq64U(v) case OpLeq8: return rewriteValuegeneric_OpLeq8(v) case OpLeq8U: return rewriteValuegeneric_OpLeq8U(v) case OpLess16: return rewriteValuegeneric_OpLess16(v) case OpLess16U: return rewriteValuegeneric_OpLess16U(v) case OpLess32: return rewriteValuegeneric_OpLess32(v) case OpLess32F: return rewriteValuegeneric_OpLess32F(v) case OpLess32U: return rewriteValuegeneric_OpLess32U(v) case OpLess64: return rewriteValuegeneric_OpLess64(v) case OpLess64F: return rewriteValuegeneric_OpLess64F(v) case OpLess64U: return rewriteValuegeneric_OpLess64U(v) case OpLess8: return rewriteValuegeneric_OpLess8(v) case OpLess8U: return rewriteValuegeneric_OpLess8U(v) case OpLoad: return rewriteValuegeneric_OpLoad(v) case OpLsh16x16: return rewriteValuegeneric_OpLsh16x16(v) case OpLsh16x32: return rewriteValuegeneric_OpLsh16x32(v) case OpLsh16x64: return rewriteValuegeneric_OpLsh16x64(v) case OpLsh16x8: return rewriteValuegeneric_OpLsh16x8(v) case OpLsh32x16: return rewriteValuegeneric_OpLsh32x16(v) case OpLsh32x32: return rewriteValuegeneric_OpLsh32x32(v) case OpLsh32x64: return rewriteValuegeneric_OpLsh32x64(v) case OpLsh32x8: return rewriteValuegeneric_OpLsh32x8(v) case OpLsh64x16: return rewriteValuegeneric_OpLsh64x16(v) case OpLsh64x32: return rewriteValuegeneric_OpLsh64x32(v) case OpLsh64x64: return rewriteValuegeneric_OpLsh64x64(v) case OpLsh64x8: return rewriteValuegeneric_OpLsh64x8(v) case OpLsh8x16: return rewriteValuegeneric_OpLsh8x16(v) case OpLsh8x32: return rewriteValuegeneric_OpLsh8x32(v) case OpLsh8x64: return rewriteValuegeneric_OpLsh8x64(v) case OpLsh8x8: return rewriteValuegeneric_OpLsh8x8(v) case OpMod16: return rewriteValuegeneric_OpMod16(v) case OpMod16u: return rewriteValuegeneric_OpMod16u(v) case OpMod32: return rewriteValuegeneric_OpMod32(v) case OpMod32u: return rewriteValuegeneric_OpMod32u(v) case OpMod64: return rewriteValuegeneric_OpMod64(v) case OpMod64u: return rewriteValuegeneric_OpMod64u(v) case OpMod8: return rewriteValuegeneric_OpMod8(v) case OpMod8u: return rewriteValuegeneric_OpMod8u(v) case OpMove: return rewriteValuegeneric_OpMove(v) case OpMul16: return rewriteValuegeneric_OpMul16(v) case OpMul32: return rewriteValuegeneric_OpMul32(v) case OpMul32F: return rewriteValuegeneric_OpMul32F(v) case OpMul64: return rewriteValuegeneric_OpMul64(v) case OpMul64F: return rewriteValuegeneric_OpMul64F(v) case OpMul8: return rewriteValuegeneric_OpMul8(v) case OpNeg16: return rewriteValuegeneric_OpNeg16(v) case OpNeg32: return rewriteValuegeneric_OpNeg32(v) case OpNeg32F: return rewriteValuegeneric_OpNeg32F(v) case OpNeg64: return rewriteValuegeneric_OpNeg64(v) case OpNeg64F: return rewriteValuegeneric_OpNeg64F(v) case OpNeg8: return rewriteValuegeneric_OpNeg8(v) case OpNeq16: return rewriteValuegeneric_OpNeq16(v) case OpNeq32: return rewriteValuegeneric_OpNeq32(v) case OpNeq32F: return rewriteValuegeneric_OpNeq32F(v) case OpNeq64: return rewriteValuegeneric_OpNeq64(v) case OpNeq64F: return rewriteValuegeneric_OpNeq64F(v) case OpNeq8: return rewriteValuegeneric_OpNeq8(v) case OpNeqB: return rewriteValuegeneric_OpNeqB(v) case OpNeqInter: return rewriteValuegeneric_OpNeqInter(v) case OpNeqPtr: return rewriteValuegeneric_OpNeqPtr(v) case OpNeqSlice: return rewriteValuegeneric_OpNeqSlice(v) case OpNilCheck: return rewriteValuegeneric_OpNilCheck(v) case OpNot: return rewriteValuegeneric_OpNot(v) case OpOffPtr: return rewriteValuegeneric_OpOffPtr(v) case OpOr16: return rewriteValuegeneric_OpOr16(v) case OpOr32: return rewriteValuegeneric_OpOr32(v) case OpOr64: return rewriteValuegeneric_OpOr64(v) case OpOr8: return rewriteValuegeneric_OpOr8(v) case OpOrB: return rewriteValuegeneric_OpOrB(v) case OpPhi: return rewriteValuegeneric_OpPhi(v) case OpPtrIndex: return rewriteValuegeneric_OpPtrIndex(v) case OpRotateLeft16: return rewriteValuegeneric_OpRotateLeft16(v) case OpRotateLeft32: return rewriteValuegeneric_OpRotateLeft32(v) case OpRotateLeft64: return rewriteValuegeneric_OpRotateLeft64(v) case OpRotateLeft8: return rewriteValuegeneric_OpRotateLeft8(v) case OpRound32F: return rewriteValuegeneric_OpRound32F(v) case OpRound64F: return rewriteValuegeneric_OpRound64F(v) case OpRsh16Ux16: return rewriteValuegeneric_OpRsh16Ux16(v) case OpRsh16Ux32: return rewriteValuegeneric_OpRsh16Ux32(v) case OpRsh16Ux64: return rewriteValuegeneric_OpRsh16Ux64(v) case OpRsh16Ux8: return rewriteValuegeneric_OpRsh16Ux8(v) case OpRsh16x16: return rewriteValuegeneric_OpRsh16x16(v) case OpRsh16x32: return rewriteValuegeneric_OpRsh16x32(v) case OpRsh16x64: return rewriteValuegeneric_OpRsh16x64(v) case OpRsh16x8: return rewriteValuegeneric_OpRsh16x8(v) case OpRsh32Ux16: return rewriteValuegeneric_OpRsh32Ux16(v) case OpRsh32Ux32: return rewriteValuegeneric_OpRsh32Ux32(v) case OpRsh32Ux64: return rewriteValuegeneric_OpRsh32Ux64(v) case OpRsh32Ux8: return rewriteValuegeneric_OpRsh32Ux8(v) case OpRsh32x16: return rewriteValuegeneric_OpRsh32x16(v) case OpRsh32x32: return rewriteValuegeneric_OpRsh32x32(v) case OpRsh32x64: return rewriteValuegeneric_OpRsh32x64(v) case OpRsh32x8: return rewriteValuegeneric_OpRsh32x8(v) case OpRsh64Ux16: return rewriteValuegeneric_OpRsh64Ux16(v) case OpRsh64Ux32: return rewriteValuegeneric_OpRsh64Ux32(v) case OpRsh64Ux64: return rewriteValuegeneric_OpRsh64Ux64(v) case OpRsh64Ux8: return rewriteValuegeneric_OpRsh64Ux8(v) case OpRsh64x16: return rewriteValuegeneric_OpRsh64x16(v) case OpRsh64x32: return rewriteValuegeneric_OpRsh64x32(v) case OpRsh64x64: return rewriteValuegeneric_OpRsh64x64(v) case OpRsh64x8: return rewriteValuegeneric_OpRsh64x8(v) case OpRsh8Ux16: return rewriteValuegeneric_OpRsh8Ux16(v) case OpRsh8Ux32: return rewriteValuegeneric_OpRsh8Ux32(v) case OpRsh8Ux64: return rewriteValuegeneric_OpRsh8Ux64(v) case OpRsh8Ux8: return rewriteValuegeneric_OpRsh8Ux8(v) case OpRsh8x16: return rewriteValuegeneric_OpRsh8x16(v) case OpRsh8x32: return rewriteValuegeneric_OpRsh8x32(v) case OpRsh8x64: return rewriteValuegeneric_OpRsh8x64(v) case OpRsh8x8: return rewriteValuegeneric_OpRsh8x8(v) case OpSelect0: return rewriteValuegeneric_OpSelect0(v) case OpSelect1: return rewriteValuegeneric_OpSelect1(v) case OpSignExt16to32: return rewriteValuegeneric_OpSignExt16to32(v) case OpSignExt16to64: return rewriteValuegeneric_OpSignExt16to64(v) case OpSignExt32to64: return rewriteValuegeneric_OpSignExt32to64(v) case OpSignExt8to16: return rewriteValuegeneric_OpSignExt8to16(v) case OpSignExt8to32: return rewriteValuegeneric_OpSignExt8to32(v) case OpSignExt8to64: return rewriteValuegeneric_OpSignExt8to64(v) case OpSliceCap: return rewriteValuegeneric_OpSliceCap(v) case OpSliceLen: return rewriteValuegeneric_OpSliceLen(v) case OpSlicePtr: return rewriteValuegeneric_OpSlicePtr(v) case OpSlicemask: return rewriteValuegeneric_OpSlicemask(v) case OpSqrt: return rewriteValuegeneric_OpSqrt(v) case OpStaticCall: return rewriteValuegeneric_OpStaticCall(v) case OpStore: return rewriteValuegeneric_OpStore(v) case OpStringLen: return rewriteValuegeneric_OpStringLen(v) case OpStringPtr: return rewriteValuegeneric_OpStringPtr(v) case OpStructSelect: return rewriteValuegeneric_OpStructSelect(v) case OpSub16: return rewriteValuegeneric_OpSub16(v) case OpSub32: return rewriteValuegeneric_OpSub32(v) case OpSub32F: return rewriteValuegeneric_OpSub32F(v) case OpSub64: return rewriteValuegeneric_OpSub64(v) case OpSub64F: return rewriteValuegeneric_OpSub64F(v) case OpSub8: return rewriteValuegeneric_OpSub8(v) case OpTrunc16to8: return rewriteValuegeneric_OpTrunc16to8(v) case OpTrunc32to16: return rewriteValuegeneric_OpTrunc32to16(v) case OpTrunc32to8: return rewriteValuegeneric_OpTrunc32to8(v) case OpTrunc64to16: return rewriteValuegeneric_OpTrunc64to16(v) case OpTrunc64to32: return rewriteValuegeneric_OpTrunc64to32(v) case OpTrunc64to8: return rewriteValuegeneric_OpTrunc64to8(v) case OpXor16: return rewriteValuegeneric_OpXor16(v) case OpXor32: return rewriteValuegeneric_OpXor32(v) case OpXor64: return rewriteValuegeneric_OpXor64(v) case OpXor8: return rewriteValuegeneric_OpXor8(v) case OpZero: return rewriteValuegeneric_OpZero(v) case OpZeroExt16to32: return rewriteValuegeneric_OpZeroExt16to32(v) case OpZeroExt16to64: return rewriteValuegeneric_OpZeroExt16to64(v) case OpZeroExt32to64: return rewriteValuegeneric_OpZeroExt32to64(v) case OpZeroExt8to16: return rewriteValuegeneric_OpZeroExt8to16(v) case OpZeroExt8to32: return rewriteValuegeneric_OpZeroExt8to32(v) case OpZeroExt8to64: return rewriteValuegeneric_OpZeroExt8to64(v) } return false } func rewriteValuegeneric_OpAdd16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Add16 (Const16 [c]) (Const16 [d])) // result: (Const16 [c+d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c + d) return true } break } // match: (Add16 <t> (Mul16 x y) (Mul16 x z)) // result: (Mul16 x (Add16 <t> y z)) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpMul16 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if v_1.Op != OpMul16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { if x != v_1_0 { continue } z := v_1_1 v.reset(OpMul16) v0 := b.NewValue0(v.Pos, OpAdd16, t) v0.AddArg2(y, z) v.AddArg2(x, v0) return true } } } break } // match: (Add16 (Const16 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Add16 (Const16 [1]) (Com16 x)) // result: (Neg16 x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 1 || v_1.Op != OpCom16 { continue } x := v_1.Args[0] v.reset(OpNeg16) v.AddArg(x) return true } break } // match: (Add16 (Add16 i:(Const16 <t>) z) x) // cond: (z.Op != OpConst16 && x.Op != OpConst16) // result: (Add16 i (Add16 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAdd16 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst16 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst16 && x.Op != OpConst16) { continue } v.reset(OpAdd16) v0 := b.NewValue0(v.Pos, OpAdd16, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Add16 (Sub16 i:(Const16 <t>) z) x) // cond: (z.Op != OpConst16 && x.Op != OpConst16) // result: (Add16 i (Sub16 <t> x z)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpSub16 { continue } z := v_0.Args[1] i := v_0.Args[0] if i.Op != OpConst16 { continue } t := i.Type x := v_1 if !(z.Op != OpConst16 && x.Op != OpConst16) { continue } v.reset(OpAdd16) v0 := b.NewValue0(v.Pos, OpSub16, t) v0.AddArg2(x, z) v.AddArg2(i, v0) return true } break } // match: (Add16 (Sub16 z i:(Const16 <t>)) x) // cond: (z.Op != OpConst16 && x.Op != OpConst16) // result: (Sub16 (Add16 <t> x z) i) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpSub16 { continue } _ = v_0.Args[1] z := v_0.Args[0] i := v_0.Args[1] if i.Op != OpConst16 { continue } t := i.Type x := v_1 if !(z.Op != OpConst16 && x.Op != OpConst16) { continue } v.reset(OpSub16) v0 := b.NewValue0(v.Pos, OpAdd16, t) v0.AddArg2(x, z) v.AddArg2(v0, i) return true } break } // match: (Add16 (Const16 <t> [c]) (Add16 (Const16 <t> [d]) x)) // result: (Add16 (Const16 <t> [c+d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpAdd16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 || v_1_0.Type != t { continue } d := auxIntToInt16(v_1_0.AuxInt) x := v_1_1 v.reset(OpAdd16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c + d) v.AddArg2(v0, x) return true } } break } // match: (Add16 (Const16 <t> [c]) (Sub16 (Const16 <t> [d]) x)) // result: (Sub16 (Const16 <t> [c+d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpSub16 { continue } x := v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpConst16 || v_1_0.Type != t { continue } d := auxIntToInt16(v_1_0.AuxInt) v.reset(OpSub16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c + d) v.AddArg2(v0, x) return true } break } // match: (Add16 (Const16 <t> [c]) (Sub16 x (Const16 <t> [d]))) // result: (Add16 (Const16 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpSub16 { continue } _ = v_1.Args[1] x := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 || v_1_1.Type != t { continue } d := auxIntToInt16(v_1_1.AuxInt) v.reset(OpAdd16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c - d) v.AddArg2(v0, x) return true } break } return false } func rewriteValuegeneric_OpAdd32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Add32 (Const32 [c]) (Const32 [d])) // result: (Const32 [c+d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c + d) return true } break } // match: (Add32 <t> (Mul32 x y) (Mul32 x z)) // result: (Mul32 x (Add32 <t> y z)) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpMul32 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { if x != v_1_0 { continue } z := v_1_1 v.reset(OpMul32) v0 := b.NewValue0(v.Pos, OpAdd32, t) v0.AddArg2(y, z) v.AddArg2(x, v0) return true } } } break } // match: (Add32 (Const32 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Add32 (Const32 [1]) (Com32 x)) // result: (Neg32 x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 1 || v_1.Op != OpCom32 { continue } x := v_1.Args[0] v.reset(OpNeg32) v.AddArg(x) return true } break } // match: (Add32 (Add32 i:(Const32 <t>) z) x) // cond: (z.Op != OpConst32 && x.Op != OpConst32) // result: (Add32 i (Add32 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAdd32 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst32 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst32 && x.Op != OpConst32) { continue } v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpAdd32, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Add32 (Sub32 i:(Const32 <t>) z) x) // cond: (z.Op != OpConst32 && x.Op != OpConst32) // result: (Add32 i (Sub32 <t> x z)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpSub32 { continue } z := v_0.Args[1] i := v_0.Args[0] if i.Op != OpConst32 { continue } t := i.Type x := v_1 if !(z.Op != OpConst32 && x.Op != OpConst32) { continue } v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpSub32, t) v0.AddArg2(x, z) v.AddArg2(i, v0) return true } break } // match: (Add32 (Sub32 z i:(Const32 <t>)) x) // cond: (z.Op != OpConst32 && x.Op != OpConst32) // result: (Sub32 (Add32 <t> x z) i) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpSub32 { continue } _ = v_0.Args[1] z := v_0.Args[0] i := v_0.Args[1] if i.Op != OpConst32 { continue } t := i.Type x := v_1 if !(z.Op != OpConst32 && x.Op != OpConst32) { continue } v.reset(OpSub32) v0 := b.NewValue0(v.Pos, OpAdd32, t) v0.AddArg2(x, z) v.AddArg2(v0, i) return true } break } // match: (Add32 (Const32 <t> [c]) (Add32 (Const32 <t> [d]) x)) // result: (Add32 (Const32 <t> [c+d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpAdd32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) x := v_1_1 v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c + d) v.AddArg2(v0, x) return true } } break } // match: (Add32 (Const32 <t> [c]) (Sub32 (Const32 <t> [d]) x)) // result: (Sub32 (Const32 <t> [c+d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpSub32 { continue } x := v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) v.reset(OpSub32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c + d) v.AddArg2(v0, x) return true } break } // match: (Add32 (Const32 <t> [c]) (Sub32 x (Const32 <t> [d]))) // result: (Add32 (Const32 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpSub32 { continue } _ = v_1.Args[1] x := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 || v_1_1.Type != t { continue } d := auxIntToInt32(v_1_1.AuxInt) v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c - d) v.AddArg2(v0, x) return true } break } return false } func rewriteValuegeneric_OpAdd32F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Add32F (Const32F [c]) (Const32F [d])) // cond: c+d == c+d // result: (Const32F [c+d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32F { continue } c := auxIntToFloat32(v_0.AuxInt) if v_1.Op != OpConst32F { continue } d := auxIntToFloat32(v_1.AuxInt) if !(c+d == c+d) { continue } v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(c + d) return true } break } return false } func rewriteValuegeneric_OpAdd64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Add64 (Const64 [c]) (Const64 [d])) // result: (Const64 [c+d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c + d) return true } break } // match: (Add64 <t> (Mul64 x y) (Mul64 x z)) // result: (Mul64 x (Add64 <t> y z)) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpMul64 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if v_1.Op != OpMul64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { if x != v_1_0 { continue } z := v_1_1 v.reset(OpMul64) v0 := b.NewValue0(v.Pos, OpAdd64, t) v0.AddArg2(y, z) v.AddArg2(x, v0) return true } } } break } // match: (Add64 (Const64 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Add64 (Const64 [1]) (Com64 x)) // result: (Neg64 x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 1 || v_1.Op != OpCom64 { continue } x := v_1.Args[0] v.reset(OpNeg64) v.AddArg(x) return true } break } // match: (Add64 (Add64 i:(Const64 <t>) z) x) // cond: (z.Op != OpConst64 && x.Op != OpConst64) // result: (Add64 i (Add64 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAdd64 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst64 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst64 && x.Op != OpConst64) { continue } v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpAdd64, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Add64 (Sub64 i:(Const64 <t>) z) x) // cond: (z.Op != OpConst64 && x.Op != OpConst64) // result: (Add64 i (Sub64 <t> x z)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpSub64 { continue } z := v_0.Args[1] i := v_0.Args[0] if i.Op != OpConst64 { continue } t := i.Type x := v_1 if !(z.Op != OpConst64 && x.Op != OpConst64) { continue } v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpSub64, t) v0.AddArg2(x, z) v.AddArg2(i, v0) return true } break } // match: (Add64 (Sub64 z i:(Const64 <t>)) x) // cond: (z.Op != OpConst64 && x.Op != OpConst64) // result: (Sub64 (Add64 <t> x z) i) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpSub64 { continue } _ = v_0.Args[1] z := v_0.Args[0] i := v_0.Args[1] if i.Op != OpConst64 { continue } t := i.Type x := v_1 if !(z.Op != OpConst64 && x.Op != OpConst64) { continue } v.reset(OpSub64) v0 := b.NewValue0(v.Pos, OpAdd64, t) v0.AddArg2(x, z) v.AddArg2(v0, i) return true } break } // match: (Add64 (Const64 <t> [c]) (Add64 (Const64 <t> [d]) x)) // result: (Add64 (Const64 <t> [c+d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpAdd64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(v0, x) return true } } break } // match: (Add64 (Const64 <t> [c]) (Sub64 (Const64 <t> [d]) x)) // result: (Sub64 (Const64 <t> [c+d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpSub64 { continue } x := v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) v.reset(OpSub64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(v0, x) return true } break } // match: (Add64 (Const64 <t> [c]) (Sub64 x (Const64 <t> [d]))) // result: (Add64 (Const64 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpSub64 { continue } _ = v_1.Args[1] x := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != t { continue } d := auxIntToInt64(v_1_1.AuxInt) v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c - d) v.AddArg2(v0, x) return true } break } return false } func rewriteValuegeneric_OpAdd64F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Add64F (Const64F [c]) (Const64F [d])) // cond: c+d == c+d // result: (Const64F [c+d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64F { continue } c := auxIntToFloat64(v_0.AuxInt) if v_1.Op != OpConst64F { continue } d := auxIntToFloat64(v_1.AuxInt) if !(c+d == c+d) { continue } v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(c + d) return true } break } return false } func rewriteValuegeneric_OpAdd8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Add8 (Const8 [c]) (Const8 [d])) // result: (Const8 [c+d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c + d) return true } break } // match: (Add8 <t> (Mul8 x y) (Mul8 x z)) // result: (Mul8 x (Add8 <t> y z)) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpMul8 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if v_1.Op != OpMul8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i2 := 0; _i2 <= 1; _i2, v_1_0, v_1_1 = _i2+1, v_1_1, v_1_0 { if x != v_1_0 { continue } z := v_1_1 v.reset(OpMul8) v0 := b.NewValue0(v.Pos, OpAdd8, t) v0.AddArg2(y, z) v.AddArg2(x, v0) return true } } } break } // match: (Add8 (Const8 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Add8 (Const8 [1]) (Com8 x)) // result: (Neg8 x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 1 || v_1.Op != OpCom8 { continue } x := v_1.Args[0] v.reset(OpNeg8) v.AddArg(x) return true } break } // match: (Add8 (Add8 i:(Const8 <t>) z) x) // cond: (z.Op != OpConst8 && x.Op != OpConst8) // result: (Add8 i (Add8 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAdd8 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst8 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst8 && x.Op != OpConst8) { continue } v.reset(OpAdd8) v0 := b.NewValue0(v.Pos, OpAdd8, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Add8 (Sub8 i:(Const8 <t>) z) x) // cond: (z.Op != OpConst8 && x.Op != OpConst8) // result: (Add8 i (Sub8 <t> x z)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpSub8 { continue } z := v_0.Args[1] i := v_0.Args[0] if i.Op != OpConst8 { continue } t := i.Type x := v_1 if !(z.Op != OpConst8 && x.Op != OpConst8) { continue } v.reset(OpAdd8) v0 := b.NewValue0(v.Pos, OpSub8, t) v0.AddArg2(x, z) v.AddArg2(i, v0) return true } break } // match: (Add8 (Sub8 z i:(Const8 <t>)) x) // cond: (z.Op != OpConst8 && x.Op != OpConst8) // result: (Sub8 (Add8 <t> x z) i) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpSub8 { continue } _ = v_0.Args[1] z := v_0.Args[0] i := v_0.Args[1] if i.Op != OpConst8 { continue } t := i.Type x := v_1 if !(z.Op != OpConst8 && x.Op != OpConst8) { continue } v.reset(OpSub8) v0 := b.NewValue0(v.Pos, OpAdd8, t) v0.AddArg2(x, z) v.AddArg2(v0, i) return true } break } // match: (Add8 (Const8 <t> [c]) (Add8 (Const8 <t> [d]) x)) // result: (Add8 (Const8 <t> [c+d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpAdd8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 || v_1_0.Type != t { continue } d := auxIntToInt8(v_1_0.AuxInt) x := v_1_1 v.reset(OpAdd8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c + d) v.AddArg2(v0, x) return true } } break } // match: (Add8 (Const8 <t> [c]) (Sub8 (Const8 <t> [d]) x)) // result: (Sub8 (Const8 <t> [c+d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpSub8 { continue } x := v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpConst8 || v_1_0.Type != t { continue } d := auxIntToInt8(v_1_0.AuxInt) v.reset(OpSub8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c + d) v.AddArg2(v0, x) return true } break } // match: (Add8 (Const8 <t> [c]) (Sub8 x (Const8 <t> [d]))) // result: (Add8 (Const8 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpSub8 { continue } _ = v_1.Args[1] x := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 || v_1_1.Type != t { continue } d := auxIntToInt8(v_1_1.AuxInt) v.reset(OpAdd8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c - d) v.AddArg2(v0, x) return true } break } return false } func rewriteValuegeneric_OpAddPtr(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (AddPtr <t> x (Const64 [c])) // result: (OffPtr <t> x [c]) for { t := v.Type x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) v.reset(OpOffPtr) v.Type = t v.AuxInt = int64ToAuxInt(c) v.AddArg(x) return true } // match: (AddPtr <t> x (Const32 [c])) // result: (OffPtr <t> x [int64(c)]) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpOffPtr) v.Type = t v.AuxInt = int64ToAuxInt(int64(c)) v.AddArg(x) return true } return false } func rewriteValuegeneric_OpAnd16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (And16 (Const16 [c]) (Const16 [d])) // result: (Const16 [c&d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c & d) return true } break } // match: (And16 (Const16 [m]) (Rsh16Ux64 _ (Const64 [c]))) // cond: c >= int64(16-ntz16(m)) // result: (Const16 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } m := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpRsh16Ux64 { continue } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= int64(16-ntz16(m))) { continue } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } break } // match: (And16 (Const16 [m]) (Lsh16x64 _ (Const64 [c]))) // cond: c >= int64(16-nlz16(m)) // result: (Const16 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } m := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpLsh16x64 { continue } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= int64(16-nlz16(m))) { continue } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } break } // match: (And16 x x) // result: x for { x := v_0 if x != v_1 { break } v.copyOf(x) return true } // match: (And16 (Const16 [-1]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != -1 { continue } x := v_1 v.copyOf(x) return true } break } // match: (And16 (Const16 [0]) _) // result: (Const16 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { continue } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } break } // match: (And16 x (And16 x y)) // result: (And16 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpAnd16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.reset(OpAnd16) v.AddArg2(x, y) return true } } break } // match: (And16 (And16 i:(Const16 <t>) z) x) // cond: (z.Op != OpConst16 && x.Op != OpConst16) // result: (And16 i (And16 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd16 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst16 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst16 && x.Op != OpConst16) { continue } v.reset(OpAnd16) v0 := b.NewValue0(v.Pos, OpAnd16, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (And16 (Const16 <t> [c]) (And16 (Const16 <t> [d]) x)) // result: (And16 (Const16 <t> [c&d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpAnd16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 || v_1_0.Type != t { continue } d := auxIntToInt16(v_1_0.AuxInt) x := v_1_1 v.reset(OpAnd16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c & d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpAnd32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (And32 (Const32 [c]) (Const32 [d])) // result: (Const32 [c&d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c & d) return true } break } // match: (And32 (Const32 [m]) (Rsh32Ux64 _ (Const64 [c]))) // cond: c >= int64(32-ntz32(m)) // result: (Const32 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } m := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpRsh32Ux64 { continue } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= int64(32-ntz32(m))) { continue } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } break } // match: (And32 (Const32 [m]) (Lsh32x64 _ (Const64 [c]))) // cond: c >= int64(32-nlz32(m)) // result: (Const32 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } m := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpLsh32x64 { continue } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= int64(32-nlz32(m))) { continue } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } break } // match: (And32 x x) // result: x for { x := v_0 if x != v_1 { break } v.copyOf(x) return true } // match: (And32 (Const32 [-1]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != -1 { continue } x := v_1 v.copyOf(x) return true } break } // match: (And32 (Const32 [0]) _) // result: (Const32 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { continue } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } break } // match: (And32 x (And32 x y)) // result: (And32 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpAnd32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.reset(OpAnd32) v.AddArg2(x, y) return true } } break } // match: (And32 (And32 i:(Const32 <t>) z) x) // cond: (z.Op != OpConst32 && x.Op != OpConst32) // result: (And32 i (And32 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd32 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst32 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst32 && x.Op != OpConst32) { continue } v.reset(OpAnd32) v0 := b.NewValue0(v.Pos, OpAnd32, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (And32 (Const32 <t> [c]) (And32 (Const32 <t> [d]) x)) // result: (And32 (Const32 <t> [c&d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpAnd32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) x := v_1_1 v.reset(OpAnd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c & d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpAnd64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (And64 (Const64 [c]) (Const64 [d])) // result: (Const64 [c&d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c & d) return true } break } // match: (And64 (Const64 [m]) (Rsh64Ux64 _ (Const64 [c]))) // cond: c >= int64(64-ntz64(m)) // result: (Const64 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } m := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpRsh64Ux64 { continue } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= int64(64-ntz64(m))) { continue } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } break } // match: (And64 (Const64 [m]) (Lsh64x64 _ (Const64 [c]))) // cond: c >= int64(64-nlz64(m)) // result: (Const64 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } m := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpLsh64x64 { continue } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= int64(64-nlz64(m))) { continue } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } break } // match: (And64 x x) // result: x for { x := v_0 if x != v_1 { break } v.copyOf(x) return true } // match: (And64 (Const64 [-1]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != -1 { continue } x := v_1 v.copyOf(x) return true } break } // match: (And64 (Const64 [0]) _) // result: (Const64 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { continue } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } break } // match: (And64 x (And64 x y)) // result: (And64 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpAnd64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.reset(OpAnd64) v.AddArg2(x, y) return true } } break } // match: (And64 (And64 i:(Const64 <t>) z) x) // cond: (z.Op != OpConst64 && x.Op != OpConst64) // result: (And64 i (And64 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd64 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst64 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst64 && x.Op != OpConst64) { continue } v.reset(OpAnd64) v0 := b.NewValue0(v.Pos, OpAnd64, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (And64 (Const64 <t> [c]) (And64 (Const64 <t> [d]) x)) // result: (And64 (Const64 <t> [c&d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpAnd64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 v.reset(OpAnd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c & d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpAnd8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (And8 (Const8 [c]) (Const8 [d])) // result: (Const8 [c&d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c & d) return true } break } // match: (And8 (Const8 [m]) (Rsh8Ux64 _ (Const64 [c]))) // cond: c >= int64(8-ntz8(m)) // result: (Const8 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } m := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpRsh8Ux64 { continue } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= int64(8-ntz8(m))) { continue } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } break } // match: (And8 (Const8 [m]) (Lsh8x64 _ (Const64 [c]))) // cond: c >= int64(8-nlz8(m)) // result: (Const8 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } m := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpLsh8x64 { continue } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= int64(8-nlz8(m))) { continue } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } break } // match: (And8 x x) // result: x for { x := v_0 if x != v_1 { break } v.copyOf(x) return true } // match: (And8 (Const8 [-1]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != -1 { continue } x := v_1 v.copyOf(x) return true } break } // match: (And8 (Const8 [0]) _) // result: (Const8 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { continue } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } break } // match: (And8 x (And8 x y)) // result: (And8 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpAnd8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.reset(OpAnd8) v.AddArg2(x, y) return true } } break } // match: (And8 (And8 i:(Const8 <t>) z) x) // cond: (z.Op != OpConst8 && x.Op != OpConst8) // result: (And8 i (And8 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd8 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst8 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst8 && x.Op != OpConst8) { continue } v.reset(OpAnd8) v0 := b.NewValue0(v.Pos, OpAnd8, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (And8 (Const8 <t> [c]) (And8 (Const8 <t> [d]) x)) // result: (And8 (Const8 <t> [c&d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpAnd8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 || v_1_0.Type != t { continue } d := auxIntToInt8(v_1_0.AuxInt) x := v_1_1 v.reset(OpAnd8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c & d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpAndB(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (AndB (Leq64 (Const64 [c]) x) (Less64 x (Const64 [d]))) // cond: d >= c // result: (Less64U (Sub64 <x.Type> x (Const64 <x.Type> [c])) (Const64 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq64 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLess64 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(d >= c) { continue } v.reset(OpLess64U) v0 := b.NewValue0(v.Pos, OpSub64, x.Type) v1 := b.NewValue0(v.Pos, OpConst64, x.Type) v1.AuxInt = int64ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq64 (Const64 [c]) x) (Leq64 x (Const64 [d]))) // cond: d >= c // result: (Leq64U (Sub64 <x.Type> x (Const64 <x.Type> [c])) (Const64 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq64 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLeq64 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(d >= c) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpSub64, x.Type) v1 := b.NewValue0(v.Pos, OpConst64, x.Type) v1.AuxInt = int64ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq32 (Const32 [c]) x) (Less32 x (Const32 [d]))) // cond: d >= c // result: (Less32U (Sub32 <x.Type> x (Const32 <x.Type> [c])) (Const32 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq32 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLess32 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(d >= c) { continue } v.reset(OpLess32U) v0 := b.NewValue0(v.Pos, OpSub32, x.Type) v1 := b.NewValue0(v.Pos, OpConst32, x.Type) v1.AuxInt = int32ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq32 (Const32 [c]) x) (Leq32 x (Const32 [d]))) // cond: d >= c // result: (Leq32U (Sub32 <x.Type> x (Const32 <x.Type> [c])) (Const32 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq32 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLeq32 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(d >= c) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpSub32, x.Type) v1 := b.NewValue0(v.Pos, OpConst32, x.Type) v1.AuxInt = int32ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq16 (Const16 [c]) x) (Less16 x (Const16 [d]))) // cond: d >= c // result: (Less16U (Sub16 <x.Type> x (Const16 <x.Type> [c])) (Const16 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq16 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLess16 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(d >= c) { continue } v.reset(OpLess16U) v0 := b.NewValue0(v.Pos, OpSub16, x.Type) v1 := b.NewValue0(v.Pos, OpConst16, x.Type) v1.AuxInt = int16ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq16 (Const16 [c]) x) (Leq16 x (Const16 [d]))) // cond: d >= c // result: (Leq16U (Sub16 <x.Type> x (Const16 <x.Type> [c])) (Const16 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq16 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLeq16 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(d >= c) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpSub16, x.Type) v1 := b.NewValue0(v.Pos, OpConst16, x.Type) v1.AuxInt = int16ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq8 (Const8 [c]) x) (Less8 x (Const8 [d]))) // cond: d >= c // result: (Less8U (Sub8 <x.Type> x (Const8 <x.Type> [c])) (Const8 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq8 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLess8 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(d >= c) { continue } v.reset(OpLess8U) v0 := b.NewValue0(v.Pos, OpSub8, x.Type) v1 := b.NewValue0(v.Pos, OpConst8, x.Type) v1.AuxInt = int8ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq8 (Const8 [c]) x) (Leq8 x (Const8 [d]))) // cond: d >= c // result: (Leq8U (Sub8 <x.Type> x (Const8 <x.Type> [c])) (Const8 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq8 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLeq8 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(d >= c) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpSub8, x.Type) v1 := b.NewValue0(v.Pos, OpConst8, x.Type) v1.AuxInt = int8ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less64 (Const64 [c]) x) (Less64 x (Const64 [d]))) // cond: d >= c+1 && c+1 > c // result: (Less64U (Sub64 <x.Type> x (Const64 <x.Type> [c+1])) (Const64 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess64 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLess64 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(d >= c+1 && c+1 > c) { continue } v.reset(OpLess64U) v0 := b.NewValue0(v.Pos, OpSub64, x.Type) v1 := b.NewValue0(v.Pos, OpConst64, x.Type) v1.AuxInt = int64ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less64 (Const64 [c]) x) (Leq64 x (Const64 [d]))) // cond: d >= c+1 && c+1 > c // result: (Leq64U (Sub64 <x.Type> x (Const64 <x.Type> [c+1])) (Const64 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess64 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLeq64 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(d >= c+1 && c+1 > c) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpSub64, x.Type) v1 := b.NewValue0(v.Pos, OpConst64, x.Type) v1.AuxInt = int64ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less32 (Const32 [c]) x) (Less32 x (Const32 [d]))) // cond: d >= c+1 && c+1 > c // result: (Less32U (Sub32 <x.Type> x (Const32 <x.Type> [c+1])) (Const32 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess32 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLess32 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(d >= c+1 && c+1 > c) { continue } v.reset(OpLess32U) v0 := b.NewValue0(v.Pos, OpSub32, x.Type) v1 := b.NewValue0(v.Pos, OpConst32, x.Type) v1.AuxInt = int32ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less32 (Const32 [c]) x) (Leq32 x (Const32 [d]))) // cond: d >= c+1 && c+1 > c // result: (Leq32U (Sub32 <x.Type> x (Const32 <x.Type> [c+1])) (Const32 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess32 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLeq32 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(d >= c+1 && c+1 > c) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpSub32, x.Type) v1 := b.NewValue0(v.Pos, OpConst32, x.Type) v1.AuxInt = int32ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less16 (Const16 [c]) x) (Less16 x (Const16 [d]))) // cond: d >= c+1 && c+1 > c // result: (Less16U (Sub16 <x.Type> x (Const16 <x.Type> [c+1])) (Const16 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess16 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLess16 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(d >= c+1 && c+1 > c) { continue } v.reset(OpLess16U) v0 := b.NewValue0(v.Pos, OpSub16, x.Type) v1 := b.NewValue0(v.Pos, OpConst16, x.Type) v1.AuxInt = int16ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less16 (Const16 [c]) x) (Leq16 x (Const16 [d]))) // cond: d >= c+1 && c+1 > c // result: (Leq16U (Sub16 <x.Type> x (Const16 <x.Type> [c+1])) (Const16 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess16 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLeq16 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(d >= c+1 && c+1 > c) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpSub16, x.Type) v1 := b.NewValue0(v.Pos, OpConst16, x.Type) v1.AuxInt = int16ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less8 (Const8 [c]) x) (Less8 x (Const8 [d]))) // cond: d >= c+1 && c+1 > c // result: (Less8U (Sub8 <x.Type> x (Const8 <x.Type> [c+1])) (Const8 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess8 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLess8 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(d >= c+1 && c+1 > c) { continue } v.reset(OpLess8U) v0 := b.NewValue0(v.Pos, OpSub8, x.Type) v1 := b.NewValue0(v.Pos, OpConst8, x.Type) v1.AuxInt = int8ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less8 (Const8 [c]) x) (Leq8 x (Const8 [d]))) // cond: d >= c+1 && c+1 > c // result: (Leq8U (Sub8 <x.Type> x (Const8 <x.Type> [c+1])) (Const8 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess8 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLeq8 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(d >= c+1 && c+1 > c) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpSub8, x.Type) v1 := b.NewValue0(v.Pos, OpConst8, x.Type) v1.AuxInt = int8ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq64U (Const64 [c]) x) (Less64U x (Const64 [d]))) // cond: uint64(d) >= uint64(c) // result: (Less64U (Sub64 <x.Type> x (Const64 <x.Type> [c])) (Const64 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq64U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLess64U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(uint64(d) >= uint64(c)) { continue } v.reset(OpLess64U) v0 := b.NewValue0(v.Pos, OpSub64, x.Type) v1 := b.NewValue0(v.Pos, OpConst64, x.Type) v1.AuxInt = int64ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq64U (Const64 [c]) x) (Leq64U x (Const64 [d]))) // cond: uint64(d) >= uint64(c) // result: (Leq64U (Sub64 <x.Type> x (Const64 <x.Type> [c])) (Const64 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq64U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLeq64U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(uint64(d) >= uint64(c)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpSub64, x.Type) v1 := b.NewValue0(v.Pos, OpConst64, x.Type) v1.AuxInt = int64ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq32U (Const32 [c]) x) (Less32U x (Const32 [d]))) // cond: uint32(d) >= uint32(c) // result: (Less32U (Sub32 <x.Type> x (Const32 <x.Type> [c])) (Const32 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq32U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLess32U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(uint32(d) >= uint32(c)) { continue } v.reset(OpLess32U) v0 := b.NewValue0(v.Pos, OpSub32, x.Type) v1 := b.NewValue0(v.Pos, OpConst32, x.Type) v1.AuxInt = int32ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq32U (Const32 [c]) x) (Leq32U x (Const32 [d]))) // cond: uint32(d) >= uint32(c) // result: (Leq32U (Sub32 <x.Type> x (Const32 <x.Type> [c])) (Const32 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq32U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLeq32U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(uint32(d) >= uint32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpSub32, x.Type) v1 := b.NewValue0(v.Pos, OpConst32, x.Type) v1.AuxInt = int32ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq16U (Const16 [c]) x) (Less16U x (Const16 [d]))) // cond: uint16(d) >= uint16(c) // result: (Less16U (Sub16 <x.Type> x (Const16 <x.Type> [c])) (Const16 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq16U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLess16U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(uint16(d) >= uint16(c)) { continue } v.reset(OpLess16U) v0 := b.NewValue0(v.Pos, OpSub16, x.Type) v1 := b.NewValue0(v.Pos, OpConst16, x.Type) v1.AuxInt = int16ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq16U (Const16 [c]) x) (Leq16U x (Const16 [d]))) // cond: uint16(d) >= uint16(c) // result: (Leq16U (Sub16 <x.Type> x (Const16 <x.Type> [c])) (Const16 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq16U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLeq16U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(uint16(d) >= uint16(c)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpSub16, x.Type) v1 := b.NewValue0(v.Pos, OpConst16, x.Type) v1.AuxInt = int16ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq8U (Const8 [c]) x) (Less8U x (Const8 [d]))) // cond: uint8(d) >= uint8(c) // result: (Less8U (Sub8 <x.Type> x (Const8 <x.Type> [c])) (Const8 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq8U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLess8U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(uint8(d) >= uint8(c)) { continue } v.reset(OpLess8U) v0 := b.NewValue0(v.Pos, OpSub8, x.Type) v1 := b.NewValue0(v.Pos, OpConst8, x.Type) v1.AuxInt = int8ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Leq8U (Const8 [c]) x) (Leq8U x (Const8 [d]))) // cond: uint8(d) >= uint8(c) // result: (Leq8U (Sub8 <x.Type> x (Const8 <x.Type> [c])) (Const8 <x.Type> [d-c])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq8U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLeq8U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(uint8(d) >= uint8(c)) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpSub8, x.Type) v1 := b.NewValue0(v.Pos, OpConst8, x.Type) v1.AuxInt = int8ToAuxInt(c) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d - c) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less64U (Const64 [c]) x) (Less64U x (Const64 [d]))) // cond: uint64(d) >= uint64(c+1) && uint64(c+1) > uint64(c) // result: (Less64U (Sub64 <x.Type> x (Const64 <x.Type> [c+1])) (Const64 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess64U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLess64U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(uint64(d) >= uint64(c+1) && uint64(c+1) > uint64(c)) { continue } v.reset(OpLess64U) v0 := b.NewValue0(v.Pos, OpSub64, x.Type) v1 := b.NewValue0(v.Pos, OpConst64, x.Type) v1.AuxInt = int64ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less64U (Const64 [c]) x) (Leq64U x (Const64 [d]))) // cond: uint64(d) >= uint64(c+1) && uint64(c+1) > uint64(c) // result: (Leq64U (Sub64 <x.Type> x (Const64 <x.Type> [c+1])) (Const64 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess64U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLeq64U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(uint64(d) >= uint64(c+1) && uint64(c+1) > uint64(c)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpSub64, x.Type) v1 := b.NewValue0(v.Pos, OpConst64, x.Type) v1.AuxInt = int64ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less32U (Const32 [c]) x) (Less32U x (Const32 [d]))) // cond: uint32(d) >= uint32(c+1) && uint32(c+1) > uint32(c) // result: (Less32U (Sub32 <x.Type> x (Const32 <x.Type> [c+1])) (Const32 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess32U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLess32U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(uint32(d) >= uint32(c+1) && uint32(c+1) > uint32(c)) { continue } v.reset(OpLess32U) v0 := b.NewValue0(v.Pos, OpSub32, x.Type) v1 := b.NewValue0(v.Pos, OpConst32, x.Type) v1.AuxInt = int32ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less32U (Const32 [c]) x) (Leq32U x (Const32 [d]))) // cond: uint32(d) >= uint32(c+1) && uint32(c+1) > uint32(c) // result: (Leq32U (Sub32 <x.Type> x (Const32 <x.Type> [c+1])) (Const32 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess32U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLeq32U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(uint32(d) >= uint32(c+1) && uint32(c+1) > uint32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpSub32, x.Type) v1 := b.NewValue0(v.Pos, OpConst32, x.Type) v1.AuxInt = int32ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less16U (Const16 [c]) x) (Less16U x (Const16 [d]))) // cond: uint16(d) >= uint16(c+1) && uint16(c+1) > uint16(c) // result: (Less16U (Sub16 <x.Type> x (Const16 <x.Type> [c+1])) (Const16 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess16U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLess16U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(uint16(d) >= uint16(c+1) && uint16(c+1) > uint16(c)) { continue } v.reset(OpLess16U) v0 := b.NewValue0(v.Pos, OpSub16, x.Type) v1 := b.NewValue0(v.Pos, OpConst16, x.Type) v1.AuxInt = int16ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less16U (Const16 [c]) x) (Leq16U x (Const16 [d]))) // cond: uint16(d) >= uint16(c+1) && uint16(c+1) > uint16(c) // result: (Leq16U (Sub16 <x.Type> x (Const16 <x.Type> [c+1])) (Const16 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess16U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLeq16U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(uint16(d) >= uint16(c+1) && uint16(c+1) > uint16(c)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpSub16, x.Type) v1 := b.NewValue0(v.Pos, OpConst16, x.Type) v1.AuxInt = int16ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less8U (Const8 [c]) x) (Less8U x (Const8 [d]))) // cond: uint8(d) >= uint8(c+1) && uint8(c+1) > uint8(c) // result: (Less8U (Sub8 <x.Type> x (Const8 <x.Type> [c+1])) (Const8 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess8U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLess8U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(uint8(d) >= uint8(c+1) && uint8(c+1) > uint8(c)) { continue } v.reset(OpLess8U) v0 := b.NewValue0(v.Pos, OpSub8, x.Type) v1 := b.NewValue0(v.Pos, OpConst8, x.Type) v1.AuxInt = int8ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } // match: (AndB (Less8U (Const8 [c]) x) (Leq8U x (Const8 [d]))) // cond: uint8(d) >= uint8(c+1) && uint8(c+1) > uint8(c) // result: (Leq8U (Sub8 <x.Type> x (Const8 <x.Type> [c+1])) (Const8 <x.Type> [d-c-1])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess8U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLeq8U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(uint8(d) >= uint8(c+1) && uint8(c+1) > uint8(c)) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpSub8, x.Type) v1 := b.NewValue0(v.Pos, OpConst8, x.Type) v1.AuxInt = int8ToAuxInt(c + 1) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d - c - 1) v.AddArg2(v0, v2) return true } break } return false } func rewriteValuegeneric_OpArraySelect(v *Value) bool { v_0 := v.Args[0] // match: (ArraySelect (ArrayMake1 x)) // result: x for { if v_0.Op != OpArrayMake1 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (ArraySelect [0] (IData x)) // result: (IData x) for { if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpIData { break } x := v_0.Args[0] v.reset(OpIData) v.AddArg(x) return true } return false } func rewriteValuegeneric_OpCom16(v *Value) bool { v_0 := v.Args[0] // match: (Com16 (Com16 x)) // result: x for { if v_0.Op != OpCom16 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Com16 (Const16 [c])) // result: (Const16 [^c]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(^c) return true } // match: (Com16 (Add16 (Const16 [-1]) x)) // result: (Neg16 x) for { if v_0.Op != OpAdd16 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst16 || auxIntToInt16(v_0_0.AuxInt) != -1 { continue } x := v_0_1 v.reset(OpNeg16) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpCom32(v *Value) bool { v_0 := v.Args[0] // match: (Com32 (Com32 x)) // result: x for { if v_0.Op != OpCom32 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Com32 (Const32 [c])) // result: (Const32 [^c]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(^c) return true } // match: (Com32 (Add32 (Const32 [-1]) x)) // result: (Neg32 x) for { if v_0.Op != OpAdd32 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst32 || auxIntToInt32(v_0_0.AuxInt) != -1 { continue } x := v_0_1 v.reset(OpNeg32) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpCom64(v *Value) bool { v_0 := v.Args[0] // match: (Com64 (Com64 x)) // result: x for { if v_0.Op != OpCom64 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Com64 (Const64 [c])) // result: (Const64 [^c]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(^c) return true } // match: (Com64 (Add64 (Const64 [-1]) x)) // result: (Neg64 x) for { if v_0.Op != OpAdd64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst64 || auxIntToInt64(v_0_0.AuxInt) != -1 { continue } x := v_0_1 v.reset(OpNeg64) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpCom8(v *Value) bool { v_0 := v.Args[0] // match: (Com8 (Com8 x)) // result: x for { if v_0.Op != OpCom8 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Com8 (Const8 [c])) // result: (Const8 [^c]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(^c) return true } // match: (Com8 (Add8 (Const8 [-1]) x)) // result: (Neg8 x) for { if v_0.Op != OpAdd8 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst8 || auxIntToInt8(v_0_0.AuxInt) != -1 { continue } x := v_0_1 v.reset(OpNeg8) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpConstInterface(v *Value) bool { b := v.Block typ := &b.Func.Config.Types // match: (ConstInterface) // result: (IMake (ConstNil <typ.Uintptr>) (ConstNil <typ.BytePtr>)) for { v.reset(OpIMake) v0 := b.NewValue0(v.Pos, OpConstNil, typ.Uintptr) v1 := b.NewValue0(v.Pos, OpConstNil, typ.BytePtr) v.AddArg2(v0, v1) return true } } func rewriteValuegeneric_OpConstSlice(v *Value) bool { b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (ConstSlice) // cond: config.PtrSize == 4 // result: (SliceMake (ConstNil <v.Type.Elem().PtrTo()>) (Const32 <typ.Int> [0]) (Const32 <typ.Int> [0])) for { if !(config.PtrSize == 4) { break } v.reset(OpSliceMake) v0 := b.NewValue0(v.Pos, OpConstNil, v.Type.Elem().PtrTo()) v1 := b.NewValue0(v.Pos, OpConst32, typ.Int) v1.AuxInt = int32ToAuxInt(0) v.AddArg3(v0, v1, v1) return true } // match: (ConstSlice) // cond: config.PtrSize == 8 // result: (SliceMake (ConstNil <v.Type.Elem().PtrTo()>) (Const64 <typ.Int> [0]) (Const64 <typ.Int> [0])) for { if !(config.PtrSize == 8) { break } v.reset(OpSliceMake) v0 := b.NewValue0(v.Pos, OpConstNil, v.Type.Elem().PtrTo()) v1 := b.NewValue0(v.Pos, OpConst64, typ.Int) v1.AuxInt = int64ToAuxInt(0) v.AddArg3(v0, v1, v1) return true } return false } func rewriteValuegeneric_OpConstString(v *Value) bool { b := v.Block config := b.Func.Config fe := b.Func.fe typ := &b.Func.Config.Types // match: (ConstString {str}) // cond: config.PtrSize == 4 && str == "" // result: (StringMake (ConstNil) (Const32 <typ.Int> [0])) for { str := auxToString(v.Aux) if !(config.PtrSize == 4 && str == "") { break } v.reset(OpStringMake) v0 := b.NewValue0(v.Pos, OpConstNil, typ.BytePtr) v1 := b.NewValue0(v.Pos, OpConst32, typ.Int) v1.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v1) return true } // match: (ConstString {str}) // cond: config.PtrSize == 8 && str == "" // result: (StringMake (ConstNil) (Const64 <typ.Int> [0])) for { str := auxToString(v.Aux) if !(config.PtrSize == 8 && str == "") { break } v.reset(OpStringMake) v0 := b.NewValue0(v.Pos, OpConstNil, typ.BytePtr) v1 := b.NewValue0(v.Pos, OpConst64, typ.Int) v1.AuxInt = int64ToAuxInt(0) v.AddArg2(v0, v1) return true } // match: (ConstString {str}) // cond: config.PtrSize == 4 && str != "" // result: (StringMake (Addr <typ.BytePtr> {fe.StringData(str)} (SB)) (Const32 <typ.Int> [int32(len(str))])) for { str := auxToString(v.Aux) if !(config.PtrSize == 4 && str != "") { break } v.reset(OpStringMake) v0 := b.NewValue0(v.Pos, OpAddr, typ.BytePtr) v0.Aux = symToAux(fe.StringData(str)) v1 := b.NewValue0(v.Pos, OpSB, typ.Uintptr) v0.AddArg(v1) v2 := b.NewValue0(v.Pos, OpConst32, typ.Int) v2.AuxInt = int32ToAuxInt(int32(len(str))) v.AddArg2(v0, v2) return true } // match: (ConstString {str}) // cond: config.PtrSize == 8 && str != "" // result: (StringMake (Addr <typ.BytePtr> {fe.StringData(str)} (SB)) (Const64 <typ.Int> [int64(len(str))])) for { str := auxToString(v.Aux) if !(config.PtrSize == 8 && str != "") { break } v.reset(OpStringMake) v0 := b.NewValue0(v.Pos, OpAddr, typ.BytePtr) v0.Aux = symToAux(fe.StringData(str)) v1 := b.NewValue0(v.Pos, OpSB, typ.Uintptr) v0.AddArg(v1) v2 := b.NewValue0(v.Pos, OpConst64, typ.Int) v2.AuxInt = int64ToAuxInt(int64(len(str))) v.AddArg2(v0, v2) return true } return false } func rewriteValuegeneric_OpConvert(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Convert (Add64 (Convert ptr mem) off) mem) // result: (AddPtr ptr off) for { if v_0.Op != OpAdd64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConvert { continue } mem := v_0_0.Args[1] ptr := v_0_0.Args[0] off := v_0_1 if mem != v_1 { continue } v.reset(OpAddPtr) v.AddArg2(ptr, off) return true } break } // match: (Convert (Add32 (Convert ptr mem) off) mem) // result: (AddPtr ptr off) for { if v_0.Op != OpAdd32 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConvert { continue } mem := v_0_0.Args[1] ptr := v_0_0.Args[0] off := v_0_1 if mem != v_1 { continue } v.reset(OpAddPtr) v.AddArg2(ptr, off) return true } break } // match: (Convert (Convert ptr mem) mem) // result: ptr for { if v_0.Op != OpConvert { break } mem := v_0.Args[1] ptr := v_0.Args[0] if mem != v_1 { break } v.copyOf(ptr) return true } return false } func rewriteValuegeneric_OpCtz16(v *Value) bool { v_0 := v.Args[0] b := v.Block config := b.Func.Config // match: (Ctz16 (Const16 [c])) // cond: config.PtrSize == 4 // result: (Const32 [int32(ntz16(c))]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if !(config.PtrSize == 4) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(ntz16(c))) return true } // match: (Ctz16 (Const16 [c])) // cond: config.PtrSize == 8 // result: (Const64 [int64(ntz16(c))]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if !(config.PtrSize == 8) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(ntz16(c))) return true } return false } func rewriteValuegeneric_OpCtz32(v *Value) bool { v_0 := v.Args[0] b := v.Block config := b.Func.Config // match: (Ctz32 (Const32 [c])) // cond: config.PtrSize == 4 // result: (Const32 [int32(ntz32(c))]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if !(config.PtrSize == 4) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(ntz32(c))) return true } // match: (Ctz32 (Const32 [c])) // cond: config.PtrSize == 8 // result: (Const64 [int64(ntz32(c))]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if !(config.PtrSize == 8) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(ntz32(c))) return true } return false } func rewriteValuegeneric_OpCtz64(v *Value) bool { v_0 := v.Args[0] b := v.Block config := b.Func.Config // match: (Ctz64 (Const64 [c])) // cond: config.PtrSize == 4 // result: (Const32 [int32(ntz64(c))]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if !(config.PtrSize == 4) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(ntz64(c))) return true } // match: (Ctz64 (Const64 [c])) // cond: config.PtrSize == 8 // result: (Const64 [int64(ntz64(c))]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if !(config.PtrSize == 8) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(ntz64(c))) return true } return false } func rewriteValuegeneric_OpCtz8(v *Value) bool { v_0 := v.Args[0] b := v.Block config := b.Func.Config // match: (Ctz8 (Const8 [c])) // cond: config.PtrSize == 4 // result: (Const32 [int32(ntz8(c))]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if !(config.PtrSize == 4) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(ntz8(c))) return true } // match: (Ctz8 (Const8 [c])) // cond: config.PtrSize == 8 // result: (Const64 [int64(ntz8(c))]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if !(config.PtrSize == 8) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(ntz8(c))) return true } return false } func rewriteValuegeneric_OpCvt32Fto32(v *Value) bool { v_0 := v.Args[0] // match: (Cvt32Fto32 (Const32F [c])) // result: (Const32 [int32(c)]) for { if v_0.Op != OpConst32F { break } c := auxIntToFloat32(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(c)) return true } return false } func rewriteValuegeneric_OpCvt32Fto64(v *Value) bool { v_0 := v.Args[0] // match: (Cvt32Fto64 (Const32F [c])) // result: (Const64 [int64(c)]) for { if v_0.Op != OpConst32F { break } c := auxIntToFloat32(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(c)) return true } return false } func rewriteValuegeneric_OpCvt32Fto64F(v *Value) bool { v_0 := v.Args[0] // match: (Cvt32Fto64F (Const32F [c])) // result: (Const64F [float64(c)]) for { if v_0.Op != OpConst32F { break } c := auxIntToFloat32(v_0.AuxInt) v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(float64(c)) return true } return false } func rewriteValuegeneric_OpCvt32to32F(v *Value) bool { v_0 := v.Args[0] // match: (Cvt32to32F (Const32 [c])) // result: (Const32F [float32(c)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(float32(c)) return true } return false } func rewriteValuegeneric_OpCvt32to64F(v *Value) bool { v_0 := v.Args[0] // match: (Cvt32to64F (Const32 [c])) // result: (Const64F [float64(c)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(float64(c)) return true } return false } func rewriteValuegeneric_OpCvt64Fto32(v *Value) bool { v_0 := v.Args[0] // match: (Cvt64Fto32 (Const64F [c])) // result: (Const32 [int32(c)]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(c)) return true } return false } func rewriteValuegeneric_OpCvt64Fto32F(v *Value) bool { v_0 := v.Args[0] // match: (Cvt64Fto32F (Const64F [c])) // result: (Const32F [float32(c)]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(float32(c)) return true } return false } func rewriteValuegeneric_OpCvt64Fto64(v *Value) bool { v_0 := v.Args[0] // match: (Cvt64Fto64 (Const64F [c])) // result: (Const64 [int64(c)]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(c)) return true } return false } func rewriteValuegeneric_OpCvt64to32F(v *Value) bool { v_0 := v.Args[0] // match: (Cvt64to32F (Const64 [c])) // result: (Const32F [float32(c)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(float32(c)) return true } return false } func rewriteValuegeneric_OpCvt64to64F(v *Value) bool { v_0 := v.Args[0] // match: (Cvt64to64F (Const64 [c])) // result: (Const64F [float64(c)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(float64(c)) return true } return false } func rewriteValuegeneric_OpCvtBoolToUint8(v *Value) bool { v_0 := v.Args[0] // match: (CvtBoolToUint8 (ConstBool [false])) // result: (Const8 [0]) for { if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != false { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (CvtBoolToUint8 (ConstBool [true])) // result: (Const8 [1]) for { if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != true { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(1) return true } return false } func rewriteValuegeneric_OpDiv16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Div16 (Const16 [c]) (Const16 [d])) // cond: d != 0 // result: (Const16 [c/d]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c / d) return true } // match: (Div16 n (Const16 [c])) // cond: isNonNegative(n) && isPowerOfTwo16(c) // result: (Rsh16Ux64 n (Const64 <typ.UInt64> [log16(c)])) for { n := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(isNonNegative(n) && isPowerOfTwo16(c)) { break } v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log16(c)) v.AddArg2(n, v0) return true } // match: (Div16 <t> n (Const16 [c])) // cond: c < 0 && c != -1<<15 // result: (Neg16 (Div16 <t> n (Const16 <t> [-c]))) for { t := v.Type n := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(c < 0 && c != -1<<15) { break } v.reset(OpNeg16) v0 := b.NewValue0(v.Pos, OpDiv16, t) v1 := b.NewValue0(v.Pos, OpConst16, t) v1.AuxInt = int16ToAuxInt(-c) v0.AddArg2(n, v1) v.AddArg(v0) return true } // match: (Div16 <t> x (Const16 [-1<<15])) // result: (Rsh16Ux64 (And16 <t> x (Neg16 <t> x)) (Const64 <typ.UInt64> [15])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != -1<<15 { break } v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpAnd16, t) v1 := b.NewValue0(v.Pos, OpNeg16, t) v1.AddArg(x) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(15) v.AddArg2(v0, v2) return true } // match: (Div16 <t> n (Const16 [c])) // cond: isPowerOfTwo16(c) // result: (Rsh16x64 (Add16 <t> n (Rsh16Ux64 <t> (Rsh16x64 <t> n (Const64 <typ.UInt64> [15])) (Const64 <typ.UInt64> [int64(16-log16(c))]))) (Const64 <typ.UInt64> [int64(log16(c))])) for { t := v.Type n := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(isPowerOfTwo16(c)) { break } v.reset(OpRsh16x64) v0 := b.NewValue0(v.Pos, OpAdd16, t) v1 := b.NewValue0(v.Pos, OpRsh16Ux64, t) v2 := b.NewValue0(v.Pos, OpRsh16x64, t) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(15) v2.AddArg2(n, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(16 - log16(c))) v1.AddArg2(v2, v4) v0.AddArg2(n, v1) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(int64(log16(c))) v.AddArg2(v0, v5) return true } // match: (Div16 <t> x (Const16 [c])) // cond: smagicOK16(c) // result: (Sub16 <t> (Rsh32x64 <t> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(smagic16(c).m)]) (SignExt16to32 x)) (Const64 <typ.UInt64> [16+smagic16(c).s])) (Rsh32x64 <t> (SignExt16to32 x) (Const64 <typ.UInt64> [31]))) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(smagicOK16(c)) { break } v.reset(OpSub16) v.Type = t v0 := b.NewValue0(v.Pos, OpRsh32x64, t) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(smagic16(c).m)) v3 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) v3.AddArg(x) v1.AddArg2(v2, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(16 + smagic16(c).s) v0.AddArg2(v1, v4) v5 := b.NewValue0(v.Pos, OpRsh32x64, t) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(31) v5.AddArg2(v3, v6) v.AddArg2(v0, v5) return true } return false } func rewriteValuegeneric_OpDiv16u(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (Div16u (Const16 [c]) (Const16 [d])) // cond: d != 0 // result: (Const16 [int16(uint16(c)/uint16(d))]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(int16(uint16(c) / uint16(d))) return true } // match: (Div16u n (Const16 [c])) // cond: isPowerOfTwo16(c) // result: (Rsh16Ux64 n (Const64 <typ.UInt64> [log16(c)])) for { n := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(isPowerOfTwo16(c)) { break } v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log16(c)) v.AddArg2(n, v0) return true } // match: (Div16u x (Const16 [c])) // cond: umagicOK16(c) && config.RegSize == 8 // result: (Trunc64to16 (Rsh64Ux64 <typ.UInt64> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(1<<16+umagic16(c).m)]) (ZeroExt16to64 x)) (Const64 <typ.UInt64> [16+umagic16(c).s]))) for { x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(umagicOK16(c) && config.RegSize == 8) { break } v.reset(OpTrunc64to16) v0 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(1<<16 + umagic16(c).m)) v3 := b.NewValue0(v.Pos, OpZeroExt16to64, typ.UInt64) v3.AddArg(x) v1.AddArg2(v2, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(16 + umagic16(c).s) v0.AddArg2(v1, v4) v.AddArg(v0) return true } // match: (Div16u x (Const16 [c])) // cond: umagicOK16(c) && config.RegSize == 4 && umagic16(c).m&1 == 0 // result: (Trunc32to16 (Rsh32Ux64 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(1<<15+umagic16(c).m/2)]) (ZeroExt16to32 x)) (Const64 <typ.UInt64> [16+umagic16(c).s-1]))) for { x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(umagicOK16(c) && config.RegSize == 4 && umagic16(c).m&1 == 0) { break } v.reset(OpTrunc32to16) v0 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(1<<15 + umagic16(c).m/2)) v3 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) v3.AddArg(x) v1.AddArg2(v2, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(16 + umagic16(c).s - 1) v0.AddArg2(v1, v4) v.AddArg(v0) return true } // match: (Div16u x (Const16 [c])) // cond: umagicOK16(c) && config.RegSize == 4 && c&1 == 0 // result: (Trunc32to16 (Rsh32Ux64 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(1<<15+(umagic16(c).m+1)/2)]) (Rsh32Ux64 <typ.UInt32> (ZeroExt16to32 x) (Const64 <typ.UInt64> [1]))) (Const64 <typ.UInt64> [16+umagic16(c).s-2]))) for { x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(umagicOK16(c) && config.RegSize == 4 && c&1 == 0) { break } v.reset(OpTrunc32to16) v0 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(1<<15 + (umagic16(c).m+1)/2)) v3 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) v4 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) v4.AddArg(x) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(1) v3.AddArg2(v4, v5) v1.AddArg2(v2, v3) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(16 + umagic16(c).s - 2) v0.AddArg2(v1, v6) v.AddArg(v0) return true } // match: (Div16u x (Const16 [c])) // cond: umagicOK16(c) && config.RegSize == 4 && config.useAvg // result: (Trunc32to16 (Rsh32Ux64 <typ.UInt32> (Avg32u (Lsh32x64 <typ.UInt32> (ZeroExt16to32 x) (Const64 <typ.UInt64> [16])) (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(umagic16(c).m)]) (ZeroExt16to32 x))) (Const64 <typ.UInt64> [16+umagic16(c).s-1]))) for { x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(umagicOK16(c) && config.RegSize == 4 && config.useAvg) { break } v.reset(OpTrunc32to16) v0 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) v1 := b.NewValue0(v.Pos, OpAvg32u, typ.UInt32) v2 := b.NewValue0(v.Pos, OpLsh32x64, typ.UInt32) v3 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) v3.AddArg(x) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(16) v2.AddArg2(v3, v4) v5 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v6.AuxInt = int32ToAuxInt(int32(umagic16(c).m)) v5.AddArg2(v6, v3) v1.AddArg2(v2, v5) v7 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v7.AuxInt = int64ToAuxInt(16 + umagic16(c).s - 1) v0.AddArg2(v1, v7) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpDiv32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (Div32 (Const32 [c]) (Const32 [d])) // cond: d != 0 // result: (Const32 [c/d]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c / d) return true } // match: (Div32 n (Const32 [c])) // cond: isNonNegative(n) && isPowerOfTwo32(c) // result: (Rsh32Ux64 n (Const64 <typ.UInt64> [log32(c)])) for { n := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(isNonNegative(n) && isPowerOfTwo32(c)) { break } v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log32(c)) v.AddArg2(n, v0) return true } // match: (Div32 <t> n (Const32 [c])) // cond: c < 0 && c != -1<<31 // result: (Neg32 (Div32 <t> n (Const32 <t> [-c]))) for { t := v.Type n := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(c < 0 && c != -1<<31) { break } v.reset(OpNeg32) v0 := b.NewValue0(v.Pos, OpDiv32, t) v1 := b.NewValue0(v.Pos, OpConst32, t) v1.AuxInt = int32ToAuxInt(-c) v0.AddArg2(n, v1) v.AddArg(v0) return true } // match: (Div32 <t> x (Const32 [-1<<31])) // result: (Rsh32Ux64 (And32 <t> x (Neg32 <t> x)) (Const64 <typ.UInt64> [31])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != -1<<31 { break } v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpAnd32, t) v1 := b.NewValue0(v.Pos, OpNeg32, t) v1.AddArg(x) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(31) v.AddArg2(v0, v2) return true } // match: (Div32 <t> n (Const32 [c])) // cond: isPowerOfTwo32(c) // result: (Rsh32x64 (Add32 <t> n (Rsh32Ux64 <t> (Rsh32x64 <t> n (Const64 <typ.UInt64> [31])) (Const64 <typ.UInt64> [int64(32-log32(c))]))) (Const64 <typ.UInt64> [int64(log32(c))])) for { t := v.Type n := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(isPowerOfTwo32(c)) { break } v.reset(OpRsh32x64) v0 := b.NewValue0(v.Pos, OpAdd32, t) v1 := b.NewValue0(v.Pos, OpRsh32Ux64, t) v2 := b.NewValue0(v.Pos, OpRsh32x64, t) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(31) v2.AddArg2(n, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(32 - log32(c))) v1.AddArg2(v2, v4) v0.AddArg2(n, v1) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(int64(log32(c))) v.AddArg2(v0, v5) return true } // match: (Div32 <t> x (Const32 [c])) // cond: smagicOK32(c) && config.RegSize == 8 // result: (Sub32 <t> (Rsh64x64 <t> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(smagic32(c).m)]) (SignExt32to64 x)) (Const64 <typ.UInt64> [32+smagic32(c).s])) (Rsh64x64 <t> (SignExt32to64 x) (Const64 <typ.UInt64> [63]))) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(smagicOK32(c) && config.RegSize == 8) { break } v.reset(OpSub32) v.Type = t v0 := b.NewValue0(v.Pos, OpRsh64x64, t) v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(smagic32(c).m)) v3 := b.NewValue0(v.Pos, OpSignExt32to64, typ.Int64) v3.AddArg(x) v1.AddArg2(v2, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(32 + smagic32(c).s) v0.AddArg2(v1, v4) v5 := b.NewValue0(v.Pos, OpRsh64x64, t) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(63) v5.AddArg2(v3, v6) v.AddArg2(v0, v5) return true } // match: (Div32 <t> x (Const32 [c])) // cond: smagicOK32(c) && config.RegSize == 4 && smagic32(c).m&1 == 0 && config.useHmul // result: (Sub32 <t> (Rsh32x64 <t> (Hmul32 <t> (Const32 <typ.UInt32> [int32(smagic32(c).m/2)]) x) (Const64 <typ.UInt64> [smagic32(c).s-1])) (Rsh32x64 <t> x (Const64 <typ.UInt64> [31]))) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(smagicOK32(c) && config.RegSize == 4 && smagic32(c).m&1 == 0 && config.useHmul) { break } v.reset(OpSub32) v.Type = t v0 := b.NewValue0(v.Pos, OpRsh32x64, t) v1 := b.NewValue0(v.Pos, OpHmul32, t) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(smagic32(c).m / 2)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(smagic32(c).s - 1) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpRsh32x64, t) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(31) v4.AddArg2(x, v5) v.AddArg2(v0, v4) return true } // match: (Div32 <t> x (Const32 [c])) // cond: smagicOK32(c) && config.RegSize == 4 && smagic32(c).m&1 != 0 && config.useHmul // result: (Sub32 <t> (Rsh32x64 <t> (Add32 <t> (Hmul32 <t> (Const32 <typ.UInt32> [int32(smagic32(c).m)]) x) x) (Const64 <typ.UInt64> [smagic32(c).s])) (Rsh32x64 <t> x (Const64 <typ.UInt64> [31]))) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(smagicOK32(c) && config.RegSize == 4 && smagic32(c).m&1 != 0 && config.useHmul) { break } v.reset(OpSub32) v.Type = t v0 := b.NewValue0(v.Pos, OpRsh32x64, t) v1 := b.NewValue0(v.Pos, OpAdd32, t) v2 := b.NewValue0(v.Pos, OpHmul32, t) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(smagic32(c).m)) v2.AddArg2(v3, x) v1.AddArg2(v2, x) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(smagic32(c).s) v0.AddArg2(v1, v4) v5 := b.NewValue0(v.Pos, OpRsh32x64, t) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(31) v5.AddArg2(x, v6) v.AddArg2(v0, v5) return true } return false } func rewriteValuegeneric_OpDiv32F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Div32F (Const32F [c]) (Const32F [d])) // cond: c/d == c/d // result: (Const32F [c/d]) for { if v_0.Op != OpConst32F { break } c := auxIntToFloat32(v_0.AuxInt) if v_1.Op != OpConst32F { break } d := auxIntToFloat32(v_1.AuxInt) if !(c/d == c/d) { break } v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(c / d) return true } // match: (Div32F x (Const32F <t> [c])) // cond: reciprocalExact32(c) // result: (Mul32F x (Const32F <t> [1/c])) for { x := v_0 if v_1.Op != OpConst32F { break } t := v_1.Type c := auxIntToFloat32(v_1.AuxInt) if !(reciprocalExact32(c)) { break } v.reset(OpMul32F) v0 := b.NewValue0(v.Pos, OpConst32F, t) v0.AuxInt = float32ToAuxInt(1 / c) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpDiv32u(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (Div32u (Const32 [c]) (Const32 [d])) // cond: d != 0 // result: (Const32 [int32(uint32(c)/uint32(d))]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(uint32(c) / uint32(d))) return true } // match: (Div32u n (Const32 [c])) // cond: isPowerOfTwo32(c) // result: (Rsh32Ux64 n (Const64 <typ.UInt64> [log32(c)])) for { n := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(isPowerOfTwo32(c)) { break } v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log32(c)) v.AddArg2(n, v0) return true } // match: (Div32u x (Const32 [c])) // cond: umagicOK32(c) && config.RegSize == 4 && umagic32(c).m&1 == 0 && config.useHmul // result: (Rsh32Ux64 <typ.UInt32> (Hmul32u <typ.UInt32> (Const32 <typ.UInt32> [int32(1<<31+umagic32(c).m/2)]) x) (Const64 <typ.UInt64> [umagic32(c).s-1])) for { x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(umagicOK32(c) && config.RegSize == 4 && umagic32(c).m&1 == 0 && config.useHmul) { break } v.reset(OpRsh32Ux64) v.Type = typ.UInt32 v0 := b.NewValue0(v.Pos, OpHmul32u, typ.UInt32) v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v1.AuxInt = int32ToAuxInt(int32(1<<31 + umagic32(c).m/2)) v0.AddArg2(v1, x) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(umagic32(c).s - 1) v.AddArg2(v0, v2) return true } // match: (Div32u x (Const32 [c])) // cond: umagicOK32(c) && config.RegSize == 4 && c&1 == 0 && config.useHmul // result: (Rsh32Ux64 <typ.UInt32> (Hmul32u <typ.UInt32> (Const32 <typ.UInt32> [int32(1<<31+(umagic32(c).m+1)/2)]) (Rsh32Ux64 <typ.UInt32> x (Const64 <typ.UInt64> [1]))) (Const64 <typ.UInt64> [umagic32(c).s-2])) for { x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(umagicOK32(c) && config.RegSize == 4 && c&1 == 0 && config.useHmul) { break } v.reset(OpRsh32Ux64) v.Type = typ.UInt32 v0 := b.NewValue0(v.Pos, OpHmul32u, typ.UInt32) v1 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v1.AuxInt = int32ToAuxInt(int32(1<<31 + (umagic32(c).m+1)/2)) v2 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(1) v2.AddArg2(x, v3) v0.AddArg2(v1, v2) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(umagic32(c).s - 2) v.AddArg2(v0, v4) return true } // match: (Div32u x (Const32 [c])) // cond: umagicOK32(c) && config.RegSize == 4 && config.useAvg && config.useHmul // result: (Rsh32Ux64 <typ.UInt32> (Avg32u x (Hmul32u <typ.UInt32> (Const32 <typ.UInt32> [int32(umagic32(c).m)]) x)) (Const64 <typ.UInt64> [umagic32(c).s-1])) for { x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(umagicOK32(c) && config.RegSize == 4 && config.useAvg && config.useHmul) { break } v.reset(OpRsh32Ux64) v.Type = typ.UInt32 v0 := b.NewValue0(v.Pos, OpAvg32u, typ.UInt32) v1 := b.NewValue0(v.Pos, OpHmul32u, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(umagic32(c).m)) v1.AddArg2(v2, x) v0.AddArg2(x, v1) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(umagic32(c).s - 1) v.AddArg2(v0, v3) return true } // match: (Div32u x (Const32 [c])) // cond: umagicOK32(c) && config.RegSize == 8 && umagic32(c).m&1 == 0 // result: (Trunc64to32 (Rsh64Ux64 <typ.UInt64> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(1<<31+umagic32(c).m/2)]) (ZeroExt32to64 x)) (Const64 <typ.UInt64> [32+umagic32(c).s-1]))) for { x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(umagicOK32(c) && config.RegSize == 8 && umagic32(c).m&1 == 0) { break } v.reset(OpTrunc64to32) v0 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(1<<31 + umagic32(c).m/2)) v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) v3.AddArg(x) v1.AddArg2(v2, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(32 + umagic32(c).s - 1) v0.AddArg2(v1, v4) v.AddArg(v0) return true } // match: (Div32u x (Const32 [c])) // cond: umagicOK32(c) && config.RegSize == 8 && c&1 == 0 // result: (Trunc64to32 (Rsh64Ux64 <typ.UInt64> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(1<<31+(umagic32(c).m+1)/2)]) (Rsh64Ux64 <typ.UInt64> (ZeroExt32to64 x) (Const64 <typ.UInt64> [1]))) (Const64 <typ.UInt64> [32+umagic32(c).s-2]))) for { x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(umagicOK32(c) && config.RegSize == 8 && c&1 == 0) { break } v.reset(OpTrunc64to32) v0 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(1<<31 + (umagic32(c).m+1)/2)) v3 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) v4 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) v4.AddArg(x) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(1) v3.AddArg2(v4, v5) v1.AddArg2(v2, v3) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(32 + umagic32(c).s - 2) v0.AddArg2(v1, v6) v.AddArg(v0) return true } // match: (Div32u x (Const32 [c])) // cond: umagicOK32(c) && config.RegSize == 8 && config.useAvg // result: (Trunc64to32 (Rsh64Ux64 <typ.UInt64> (Avg64u (Lsh64x64 <typ.UInt64> (ZeroExt32to64 x) (Const64 <typ.UInt64> [32])) (Mul64 <typ.UInt64> (Const64 <typ.UInt32> [int64(umagic32(c).m)]) (ZeroExt32to64 x))) (Const64 <typ.UInt64> [32+umagic32(c).s-1]))) for { x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(umagicOK32(c) && config.RegSize == 8 && config.useAvg) { break } v.reset(OpTrunc64to32) v0 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpAvg64u, typ.UInt64) v2 := b.NewValue0(v.Pos, OpLsh64x64, typ.UInt64) v3 := b.NewValue0(v.Pos, OpZeroExt32to64, typ.UInt64) v3.AddArg(x) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(32) v2.AddArg2(v3, v4) v5 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt32) v6.AuxInt = int64ToAuxInt(int64(umagic32(c).m)) v5.AddArg2(v6, v3) v1.AddArg2(v2, v5) v7 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v7.AuxInt = int64ToAuxInt(32 + umagic32(c).s - 1) v0.AddArg2(v1, v7) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpDiv64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (Div64 (Const64 [c]) (Const64 [d])) // cond: d != 0 // result: (Const64 [c/d]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c / d) return true } // match: (Div64 n (Const64 [c])) // cond: isNonNegative(n) && isPowerOfTwo64(c) // result: (Rsh64Ux64 n (Const64 <typ.UInt64> [log64(c)])) for { n := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(isNonNegative(n) && isPowerOfTwo64(c)) { break } v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log64(c)) v.AddArg2(n, v0) return true } // match: (Div64 n (Const64 [-1<<63])) // cond: isNonNegative(n) // result: (Const64 [0]) for { n := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1<<63 || !(isNonNegative(n)) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Div64 <t> n (Const64 [c])) // cond: c < 0 && c != -1<<63 // result: (Neg64 (Div64 <t> n (Const64 <t> [-c]))) for { t := v.Type n := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(c < 0 && c != -1<<63) { break } v.reset(OpNeg64) v0 := b.NewValue0(v.Pos, OpDiv64, t) v1 := b.NewValue0(v.Pos, OpConst64, t) v1.AuxInt = int64ToAuxInt(-c) v0.AddArg2(n, v1) v.AddArg(v0) return true } // match: (Div64 <t> x (Const64 [-1<<63])) // result: (Rsh64Ux64 (And64 <t> x (Neg64 <t> x)) (Const64 <typ.UInt64> [63])) for { t := v.Type x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1<<63 { break } v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpAnd64, t) v1 := b.NewValue0(v.Pos, OpNeg64, t) v1.AddArg(x) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(63) v.AddArg2(v0, v2) return true } // match: (Div64 <t> n (Const64 [c])) // cond: isPowerOfTwo64(c) // result: (Rsh64x64 (Add64 <t> n (Rsh64Ux64 <t> (Rsh64x64 <t> n (Const64 <typ.UInt64> [63])) (Const64 <typ.UInt64> [int64(64-log64(c))]))) (Const64 <typ.UInt64> [int64(log64(c))])) for { t := v.Type n := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(isPowerOfTwo64(c)) { break } v.reset(OpRsh64x64) v0 := b.NewValue0(v.Pos, OpAdd64, t) v1 := b.NewValue0(v.Pos, OpRsh64Ux64, t) v2 := b.NewValue0(v.Pos, OpRsh64x64, t) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(63) v2.AddArg2(n, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(64 - log64(c))) v1.AddArg2(v2, v4) v0.AddArg2(n, v1) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(int64(log64(c))) v.AddArg2(v0, v5) return true } // match: (Div64 <t> x (Const64 [c])) // cond: smagicOK64(c) && smagic64(c).m&1 == 0 && config.useHmul // result: (Sub64 <t> (Rsh64x64 <t> (Hmul64 <t> (Const64 <typ.UInt64> [int64(smagic64(c).m/2)]) x) (Const64 <typ.UInt64> [smagic64(c).s-1])) (Rsh64x64 <t> x (Const64 <typ.UInt64> [63]))) for { t := v.Type x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(smagicOK64(c) && smagic64(c).m&1 == 0 && config.useHmul) { break } v.reset(OpSub64) v.Type = t v0 := b.NewValue0(v.Pos, OpRsh64x64, t) v1 := b.NewValue0(v.Pos, OpHmul64, t) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(smagic64(c).m / 2)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(smagic64(c).s - 1) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpRsh64x64, t) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(63) v4.AddArg2(x, v5) v.AddArg2(v0, v4) return true } // match: (Div64 <t> x (Const64 [c])) // cond: smagicOK64(c) && smagic64(c).m&1 != 0 && config.useHmul // result: (Sub64 <t> (Rsh64x64 <t> (Add64 <t> (Hmul64 <t> (Const64 <typ.UInt64> [int64(smagic64(c).m)]) x) x) (Const64 <typ.UInt64> [smagic64(c).s])) (Rsh64x64 <t> x (Const64 <typ.UInt64> [63]))) for { t := v.Type x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(smagicOK64(c) && smagic64(c).m&1 != 0 && config.useHmul) { break } v.reset(OpSub64) v.Type = t v0 := b.NewValue0(v.Pos, OpRsh64x64, t) v1 := b.NewValue0(v.Pos, OpAdd64, t) v2 := b.NewValue0(v.Pos, OpHmul64, t) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(int64(smagic64(c).m)) v2.AddArg2(v3, x) v1.AddArg2(v2, x) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(smagic64(c).s) v0.AddArg2(v1, v4) v5 := b.NewValue0(v.Pos, OpRsh64x64, t) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(63) v5.AddArg2(x, v6) v.AddArg2(v0, v5) return true } return false } func rewriteValuegeneric_OpDiv64F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Div64F (Const64F [c]) (Const64F [d])) // cond: c/d == c/d // result: (Const64F [c/d]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) if v_1.Op != OpConst64F { break } d := auxIntToFloat64(v_1.AuxInt) if !(c/d == c/d) { break } v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(c / d) return true } // match: (Div64F x (Const64F <t> [c])) // cond: reciprocalExact64(c) // result: (Mul64F x (Const64F <t> [1/c])) for { x := v_0 if v_1.Op != OpConst64F { break } t := v_1.Type c := auxIntToFloat64(v_1.AuxInt) if !(reciprocalExact64(c)) { break } v.reset(OpMul64F) v0 := b.NewValue0(v.Pos, OpConst64F, t) v0.AuxInt = float64ToAuxInt(1 / c) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpDiv64u(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (Div64u (Const64 [c]) (Const64 [d])) // cond: d != 0 // result: (Const64 [int64(uint64(c)/uint64(d))]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(uint64(c) / uint64(d))) return true } // match: (Div64u n (Const64 [c])) // cond: isPowerOfTwo64(c) // result: (Rsh64Ux64 n (Const64 <typ.UInt64> [log64(c)])) for { n := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(isPowerOfTwo64(c)) { break } v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log64(c)) v.AddArg2(n, v0) return true } // match: (Div64u n (Const64 [-1<<63])) // result: (Rsh64Ux64 n (Const64 <typ.UInt64> [63])) for { n := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1<<63 { break } v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(63) v.AddArg2(n, v0) return true } // match: (Div64u x (Const64 [c])) // cond: umagicOK64(c) && config.RegSize == 8 && umagic64(c).m&1 == 0 && config.useHmul // result: (Rsh64Ux64 <typ.UInt64> (Hmul64u <typ.UInt64> (Const64 <typ.UInt64> [int64(1<<63+umagic64(c).m/2)]) x) (Const64 <typ.UInt64> [umagic64(c).s-1])) for { x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(umagicOK64(c) && config.RegSize == 8 && umagic64(c).m&1 == 0 && config.useHmul) { break } v.reset(OpRsh64Ux64) v.Type = typ.UInt64 v0 := b.NewValue0(v.Pos, OpHmul64u, typ.UInt64) v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v1.AuxInt = int64ToAuxInt(int64(1<<63 + umagic64(c).m/2)) v0.AddArg2(v1, x) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(umagic64(c).s - 1) v.AddArg2(v0, v2) return true } // match: (Div64u x (Const64 [c])) // cond: umagicOK64(c) && config.RegSize == 8 && c&1 == 0 && config.useHmul // result: (Rsh64Ux64 <typ.UInt64> (Hmul64u <typ.UInt64> (Const64 <typ.UInt64> [int64(1<<63+(umagic64(c).m+1)/2)]) (Rsh64Ux64 <typ.UInt64> x (Const64 <typ.UInt64> [1]))) (Const64 <typ.UInt64> [umagic64(c).s-2])) for { x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(umagicOK64(c) && config.RegSize == 8 && c&1 == 0 && config.useHmul) { break } v.reset(OpRsh64Ux64) v.Type = typ.UInt64 v0 := b.NewValue0(v.Pos, OpHmul64u, typ.UInt64) v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v1.AuxInt = int64ToAuxInt(int64(1<<63 + (umagic64(c).m+1)/2)) v2 := b.NewValue0(v.Pos, OpRsh64Ux64, typ.UInt64) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(1) v2.AddArg2(x, v3) v0.AddArg2(v1, v2) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(umagic64(c).s - 2) v.AddArg2(v0, v4) return true } // match: (Div64u x (Const64 [c])) // cond: umagicOK64(c) && config.RegSize == 8 && config.useAvg && config.useHmul // result: (Rsh64Ux64 <typ.UInt64> (Avg64u x (Hmul64u <typ.UInt64> (Const64 <typ.UInt64> [int64(umagic64(c).m)]) x)) (Const64 <typ.UInt64> [umagic64(c).s-1])) for { x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(umagicOK64(c) && config.RegSize == 8 && config.useAvg && config.useHmul) { break } v.reset(OpRsh64Ux64) v.Type = typ.UInt64 v0 := b.NewValue0(v.Pos, OpAvg64u, typ.UInt64) v1 := b.NewValue0(v.Pos, OpHmul64u, typ.UInt64) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(umagic64(c).m)) v1.AddArg2(v2, x) v0.AddArg2(x, v1) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(umagic64(c).s - 1) v.AddArg2(v0, v3) return true } return false } func rewriteValuegeneric_OpDiv8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Div8 (Const8 [c]) (Const8 [d])) // cond: d != 0 // result: (Const8 [c/d]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c / d) return true } // match: (Div8 n (Const8 [c])) // cond: isNonNegative(n) && isPowerOfTwo8(c) // result: (Rsh8Ux64 n (Const64 <typ.UInt64> [log8(c)])) for { n := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(isNonNegative(n) && isPowerOfTwo8(c)) { break } v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log8(c)) v.AddArg2(n, v0) return true } // match: (Div8 <t> n (Const8 [c])) // cond: c < 0 && c != -1<<7 // result: (Neg8 (Div8 <t> n (Const8 <t> [-c]))) for { t := v.Type n := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(c < 0 && c != -1<<7) { break } v.reset(OpNeg8) v0 := b.NewValue0(v.Pos, OpDiv8, t) v1 := b.NewValue0(v.Pos, OpConst8, t) v1.AuxInt = int8ToAuxInt(-c) v0.AddArg2(n, v1) v.AddArg(v0) return true } // match: (Div8 <t> x (Const8 [-1<<7 ])) // result: (Rsh8Ux64 (And8 <t> x (Neg8 <t> x)) (Const64 <typ.UInt64> [7 ])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != -1<<7 { break } v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpAnd8, t) v1 := b.NewValue0(v.Pos, OpNeg8, t) v1.AddArg(x) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(7) v.AddArg2(v0, v2) return true } // match: (Div8 <t> n (Const8 [c])) // cond: isPowerOfTwo8(c) // result: (Rsh8x64 (Add8 <t> n (Rsh8Ux64 <t> (Rsh8x64 <t> n (Const64 <typ.UInt64> [ 7])) (Const64 <typ.UInt64> [int64( 8-log8(c))]))) (Const64 <typ.UInt64> [int64(log8(c))])) for { t := v.Type n := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(isPowerOfTwo8(c)) { break } v.reset(OpRsh8x64) v0 := b.NewValue0(v.Pos, OpAdd8, t) v1 := b.NewValue0(v.Pos, OpRsh8Ux64, t) v2 := b.NewValue0(v.Pos, OpRsh8x64, t) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(7) v2.AddArg2(n, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(8 - log8(c))) v1.AddArg2(v2, v4) v0.AddArg2(n, v1) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(int64(log8(c))) v.AddArg2(v0, v5) return true } // match: (Div8 <t> x (Const8 [c])) // cond: smagicOK8(c) // result: (Sub8 <t> (Rsh32x64 <t> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(smagic8(c).m)]) (SignExt8to32 x)) (Const64 <typ.UInt64> [8+smagic8(c).s])) (Rsh32x64 <t> (SignExt8to32 x) (Const64 <typ.UInt64> [31]))) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(smagicOK8(c)) { break } v.reset(OpSub8) v.Type = t v0 := b.NewValue0(v.Pos, OpRsh32x64, t) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(smagic8(c).m)) v3 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) v3.AddArg(x) v1.AddArg2(v2, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(8 + smagic8(c).s) v0.AddArg2(v1, v4) v5 := b.NewValue0(v.Pos, OpRsh32x64, t) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(31) v5.AddArg2(v3, v6) v.AddArg2(v0, v5) return true } return false } func rewriteValuegeneric_OpDiv8u(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Div8u (Const8 [c]) (Const8 [d])) // cond: d != 0 // result: (Const8 [int8(uint8(c)/uint8(d))]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(int8(uint8(c) / uint8(d))) return true } // match: (Div8u n (Const8 [c])) // cond: isPowerOfTwo8(c) // result: (Rsh8Ux64 n (Const64 <typ.UInt64> [log8(c)])) for { n := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(isPowerOfTwo8(c)) { break } v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log8(c)) v.AddArg2(n, v0) return true } // match: (Div8u x (Const8 [c])) // cond: umagicOK8(c) // result: (Trunc32to8 (Rsh32Ux64 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(1<<8+umagic8(c).m)]) (ZeroExt8to32 x)) (Const64 <typ.UInt64> [8+umagic8(c).s]))) for { x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(umagicOK8(c)) { break } v.reset(OpTrunc32to8) v0 := b.NewValue0(v.Pos, OpRsh32Ux64, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(1<<8 + umagic8(c).m)) v3 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) v3.AddArg(x) v1.AddArg2(v2, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(8 + umagic8(c).s) v0.AddArg2(v1, v4) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpEq16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (Eq16 x x) // result: (ConstBool [true]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (Eq16 (Const16 <t> [c]) (Add16 (Const16 <t> [d]) x)) // result: (Eq16 (Const16 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpAdd16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 || v_1_0.Type != t { continue } d := auxIntToInt16(v_1_0.AuxInt) x := v_1_1 v.reset(OpEq16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c - d) v.AddArg2(v0, x) return true } } break } // match: (Eq16 (Const16 [c]) (Const16 [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } // match: (Eq16 (Mod16u x (Const16 [c])) (Const16 [0])) // cond: x.Op != OpConst16 && udivisibleOK16(c) && !hasSmallRotate(config) // result: (Eq32 (Mod32u <typ.UInt32> (ZeroExt16to32 <typ.UInt32> x) (Const32 <typ.UInt32> [int32(uint16(c))])) (Const32 <typ.UInt32> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpMod16u { continue } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst16 { continue } c := auxIntToInt16(v_0_1.AuxInt) if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 || !(x.Op != OpConst16 && udivisibleOK16(c) && !hasSmallRotate(config)) { continue } v.reset(OpEq32) v0 := b.NewValue0(v.Pos, OpMod32u, typ.UInt32) v1 := b.NewValue0(v.Pos, OpZeroExt16to32, typ.UInt32) v1.AddArg(x) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(uint16(c))) v0.AddArg2(v1, v2) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v3) return true } break } // match: (Eq16 (Mod16 x (Const16 [c])) (Const16 [0])) // cond: x.Op != OpConst16 && sdivisibleOK16(c) && !hasSmallRotate(config) // result: (Eq32 (Mod32 <typ.Int32> (SignExt16to32 <typ.Int32> x) (Const32 <typ.Int32> [int32(c)])) (Const32 <typ.Int32> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpMod16 { continue } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst16 { continue } c := auxIntToInt16(v_0_1.AuxInt) if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 || !(x.Op != OpConst16 && sdivisibleOK16(c) && !hasSmallRotate(config)) { continue } v.reset(OpEq32) v0 := b.NewValue0(v.Pos, OpMod32, typ.Int32) v1 := b.NewValue0(v.Pos, OpSignExt16to32, typ.Int32) v1.AddArg(x) v2 := b.NewValue0(v.Pos, OpConst32, typ.Int32) v2.AuxInt = int32ToAuxInt(int32(c)) v0.AddArg2(v1, v2) v3 := b.NewValue0(v.Pos, OpConst32, typ.Int32) v3.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v3) return true } break } // match: (Eq16 x (Mul16 (Const16 [c]) (Trunc64to16 (Rsh64Ux64 mul:(Mul64 (Const64 [m]) (ZeroExt16to64 x)) (Const64 [s]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<16+umagic16(c).m) && s == 16+umagic16(c).s && x.Op != OpConst16 && udivisibleOK16(c) // result: (Leq16U (RotateLeft16 <typ.UInt16> (Mul16 <typ.UInt16> (Const16 <typ.UInt16> [int16(udivisible16(c).m)]) x) (Const16 <typ.UInt16> [int16(16-udivisible16(c).k)]) ) (Const16 <typ.UInt16> [int16(udivisible16(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 { continue } c := auxIntToInt16(v_1_0.AuxInt) if v_1_1.Op != OpTrunc64to16 { continue } v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh64Ux64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul64 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if mul_1.Op != OpZeroExt16to64 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<16+umagic16(c).m) && s == 16+umagic16(c).s && x.Op != OpConst16 && udivisibleOK16(c)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpRotateLeft16, typ.UInt16) v1 := b.NewValue0(v.Pos, OpMul16, typ.UInt16) v2 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v2.AuxInt = int16ToAuxInt(int16(udivisible16(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v3.AuxInt = int16ToAuxInt(int16(16 - udivisible16(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v4.AuxInt = int16ToAuxInt(int16(udivisible16(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq16 x (Mul16 (Const16 [c]) (Trunc32to16 (Rsh32Ux64 mul:(Mul32 (Const32 [m]) (ZeroExt16to32 x)) (Const64 [s]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<15+umagic16(c).m/2) && s == 16+umagic16(c).s-1 && x.Op != OpConst16 && udivisibleOK16(c) // result: (Leq16U (RotateLeft16 <typ.UInt16> (Mul16 <typ.UInt16> (Const16 <typ.UInt16> [int16(udivisible16(c).m)]) x) (Const16 <typ.UInt16> [int16(16-udivisible16(c).k)]) ) (Const16 <typ.UInt16> [int16(udivisible16(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 { continue } c := auxIntToInt16(v_1_0.AuxInt) if v_1_1.Op != OpTrunc32to16 { continue } v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh32Ux64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul32 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if mul_1.Op != OpZeroExt16to32 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<15+umagic16(c).m/2) && s == 16+umagic16(c).s-1 && x.Op != OpConst16 && udivisibleOK16(c)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpRotateLeft16, typ.UInt16) v1 := b.NewValue0(v.Pos, OpMul16, typ.UInt16) v2 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v2.AuxInt = int16ToAuxInt(int16(udivisible16(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v3.AuxInt = int16ToAuxInt(int16(16 - udivisible16(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v4.AuxInt = int16ToAuxInt(int16(udivisible16(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq16 x (Mul16 (Const16 [c]) (Trunc32to16 (Rsh32Ux64 mul:(Mul32 (Const32 [m]) (Rsh32Ux64 (ZeroExt16to32 x) (Const64 [1]))) (Const64 [s]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<15+(umagic16(c).m+1)/2) && s == 16+umagic16(c).s-2 && x.Op != OpConst16 && udivisibleOK16(c) // result: (Leq16U (RotateLeft16 <typ.UInt16> (Mul16 <typ.UInt16> (Const16 <typ.UInt16> [int16(udivisible16(c).m)]) x) (Const16 <typ.UInt16> [int16(16-udivisible16(c).k)]) ) (Const16 <typ.UInt16> [int16(udivisible16(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 { continue } c := auxIntToInt16(v_1_0.AuxInt) if v_1_1.Op != OpTrunc32to16 { continue } v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh32Ux64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul32 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if mul_1.Op != OpRsh32Ux64 { continue } _ = mul_1.Args[1] mul_1_0 := mul_1.Args[0] if mul_1_0.Op != OpZeroExt16to32 || x != mul_1_0.Args[0] { continue } mul_1_1 := mul_1.Args[1] if mul_1_1.Op != OpConst64 || auxIntToInt64(mul_1_1.AuxInt) != 1 { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<15+(umagic16(c).m+1)/2) && s == 16+umagic16(c).s-2 && x.Op != OpConst16 && udivisibleOK16(c)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpRotateLeft16, typ.UInt16) v1 := b.NewValue0(v.Pos, OpMul16, typ.UInt16) v2 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v2.AuxInt = int16ToAuxInt(int16(udivisible16(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v3.AuxInt = int16ToAuxInt(int16(16 - udivisible16(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v4.AuxInt = int16ToAuxInt(int16(udivisible16(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq16 x (Mul16 (Const16 [c]) (Trunc32to16 (Rsh32Ux64 (Avg32u (Lsh32x64 (ZeroExt16to32 x) (Const64 [16])) mul:(Mul32 (Const32 [m]) (ZeroExt16to32 x))) (Const64 [s]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(umagic16(c).m) && s == 16+umagic16(c).s-1 && x.Op != OpConst16 && udivisibleOK16(c) // result: (Leq16U (RotateLeft16 <typ.UInt16> (Mul16 <typ.UInt16> (Const16 <typ.UInt16> [int16(udivisible16(c).m)]) x) (Const16 <typ.UInt16> [int16(16-udivisible16(c).k)]) ) (Const16 <typ.UInt16> [int16(udivisible16(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 { continue } c := auxIntToInt16(v_1_0.AuxInt) if v_1_1.Op != OpTrunc32to16 { continue } v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh32Ux64 { continue } _ = v_1_1_0.Args[1] v_1_1_0_0 := v_1_1_0.Args[0] if v_1_1_0_0.Op != OpAvg32u { continue } _ = v_1_1_0_0.Args[1] v_1_1_0_0_0 := v_1_1_0_0.Args[0] if v_1_1_0_0_0.Op != OpLsh32x64 { continue } _ = v_1_1_0_0_0.Args[1] v_1_1_0_0_0_0 := v_1_1_0_0_0.Args[0] if v_1_1_0_0_0_0.Op != OpZeroExt16to32 || x != v_1_1_0_0_0_0.Args[0] { continue } v_1_1_0_0_0_1 := v_1_1_0_0_0.Args[1] if v_1_1_0_0_0_1.Op != OpConst64 || auxIntToInt64(v_1_1_0_0_0_1.AuxInt) != 16 { continue } mul := v_1_1_0_0.Args[1] if mul.Op != OpMul32 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if mul_1.Op != OpZeroExt16to32 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(umagic16(c).m) && s == 16+umagic16(c).s-1 && x.Op != OpConst16 && udivisibleOK16(c)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpRotateLeft16, typ.UInt16) v1 := b.NewValue0(v.Pos, OpMul16, typ.UInt16) v2 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v2.AuxInt = int16ToAuxInt(int16(udivisible16(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v3.AuxInt = int16ToAuxInt(int16(16 - udivisible16(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v4.AuxInt = int16ToAuxInt(int16(udivisible16(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq16 x (Mul16 (Const16 [c]) (Sub16 (Rsh32x64 mul:(Mul32 (Const32 [m]) (SignExt16to32 x)) (Const64 [s])) (Rsh32x64 (SignExt16to32 x) (Const64 [31]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(smagic16(c).m) && s == 16+smagic16(c).s && x.Op != OpConst16 && sdivisibleOK16(c) // result: (Leq16U (RotateLeft16 <typ.UInt16> (Add16 <typ.UInt16> (Mul16 <typ.UInt16> (Const16 <typ.UInt16> [int16(sdivisible16(c).m)]) x) (Const16 <typ.UInt16> [int16(sdivisible16(c).a)]) ) (Const16 <typ.UInt16> [int16(16-sdivisible16(c).k)]) ) (Const16 <typ.UInt16> [int16(sdivisible16(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 { continue } c := auxIntToInt16(v_1_0.AuxInt) if v_1_1.Op != OpSub16 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh32x64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul32 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if mul_1.Op != OpSignExt16to32 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpRsh32x64 { continue } _ = v_1_1_1.Args[1] v_1_1_1_0 := v_1_1_1.Args[0] if v_1_1_1_0.Op != OpSignExt16to32 || x != v_1_1_1_0.Args[0] { continue } v_1_1_1_1 := v_1_1_1.Args[1] if v_1_1_1_1.Op != OpConst64 || auxIntToInt64(v_1_1_1_1.AuxInt) != 31 || !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(smagic16(c).m) && s == 16+smagic16(c).s && x.Op != OpConst16 && sdivisibleOK16(c)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpRotateLeft16, typ.UInt16) v1 := b.NewValue0(v.Pos, OpAdd16, typ.UInt16) v2 := b.NewValue0(v.Pos, OpMul16, typ.UInt16) v3 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v3.AuxInt = int16ToAuxInt(int16(sdivisible16(c).m)) v2.AddArg2(v3, x) v4 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v4.AuxInt = int16ToAuxInt(int16(sdivisible16(c).a)) v1.AddArg2(v2, v4) v5 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v5.AuxInt = int16ToAuxInt(int16(16 - sdivisible16(c).k)) v0.AddArg2(v1, v5) v6 := b.NewValue0(v.Pos, OpConst16, typ.UInt16) v6.AuxInt = int16ToAuxInt(int16(sdivisible16(c).max)) v.AddArg2(v0, v6) return true } } } break } // match: (Eq16 n (Lsh16x64 (Rsh16x64 (Add16 <t> n (Rsh16Ux64 <t> (Rsh16x64 <t> n (Const64 <typ.UInt64> [15])) (Const64 <typ.UInt64> [kbar]))) (Const64 <typ.UInt64> [k])) (Const64 <typ.UInt64> [k])) ) // cond: k > 0 && k < 15 && kbar == 16 - k // result: (Eq16 (And16 <t> n (Const16 <t> [1<<uint(k)-1])) (Const16 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpLsh16x64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpRsh16x64 { continue } _ = v_1_0.Args[1] v_1_0_0 := v_1_0.Args[0] if v_1_0_0.Op != OpAdd16 { continue } t := v_1_0_0.Type _ = v_1_0_0.Args[1] v_1_0_0_0 := v_1_0_0.Args[0] v_1_0_0_1 := v_1_0_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0_0_0, v_1_0_0_1 = _i1+1, v_1_0_0_1, v_1_0_0_0 { if n != v_1_0_0_0 || v_1_0_0_1.Op != OpRsh16Ux64 || v_1_0_0_1.Type != t { continue } _ = v_1_0_0_1.Args[1] v_1_0_0_1_0 := v_1_0_0_1.Args[0] if v_1_0_0_1_0.Op != OpRsh16x64 || v_1_0_0_1_0.Type != t { continue } _ = v_1_0_0_1_0.Args[1] if n != v_1_0_0_1_0.Args[0] { continue } v_1_0_0_1_0_1 := v_1_0_0_1_0.Args[1] if v_1_0_0_1_0_1.Op != OpConst64 || v_1_0_0_1_0_1.Type != typ.UInt64 || auxIntToInt64(v_1_0_0_1_0_1.AuxInt) != 15 { continue } v_1_0_0_1_1 := v_1_0_0_1.Args[1] if v_1_0_0_1_1.Op != OpConst64 || v_1_0_0_1_1.Type != typ.UInt64 { continue } kbar := auxIntToInt64(v_1_0_0_1_1.AuxInt) v_1_0_1 := v_1_0.Args[1] if v_1_0_1.Op != OpConst64 || v_1_0_1.Type != typ.UInt64 { continue } k := auxIntToInt64(v_1_0_1.AuxInt) v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != typ.UInt64 || auxIntToInt64(v_1_1.AuxInt) != k || !(k > 0 && k < 15 && kbar == 16-k) { continue } v.reset(OpEq16) v0 := b.NewValue0(v.Pos, OpAnd16, t) v1 := b.NewValue0(v.Pos, OpConst16, t) v1.AuxInt = int16ToAuxInt(1<<uint(k) - 1) v0.AddArg2(n, v1) v2 := b.NewValue0(v.Pos, OpConst16, t) v2.AuxInt = int16ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } // match: (Eq16 s:(Sub16 x y) (Const16 [0])) // cond: s.Uses == 1 // result: (Eq16 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { s := v_0 if s.Op != OpSub16 { continue } y := s.Args[1] x := s.Args[0] if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 || !(s.Uses == 1) { continue } v.reset(OpEq16) v.AddArg2(x, y) return true } break } // match: (Eq16 (And16 <t> x (Const16 <t> [y])) (Const16 <t> [y])) // cond: oneBit16(y) // result: (Neq16 (And16 <t> x (Const16 <t> [y])) (Const16 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd16 { continue } t := v_0.Type _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst16 || v_0_1.Type != t { continue } y := auxIntToInt16(v_0_1.AuxInt) if v_1.Op != OpConst16 || v_1.Type != t || auxIntToInt16(v_1.AuxInt) != y || !(oneBit16(y)) { continue } v.reset(OpNeq16) v0 := b.NewValue0(v.Pos, OpAnd16, t) v1 := b.NewValue0(v.Pos, OpConst16, t) v1.AuxInt = int16ToAuxInt(y) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, t) v2.AuxInt = int16ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } return false } func rewriteValuegeneric_OpEq32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Eq32 x x) // result: (ConstBool [true]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (Eq32 (Const32 <t> [c]) (Add32 (Const32 <t> [d]) x)) // result: (Eq32 (Const32 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpAdd32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) x := v_1_1 v.reset(OpEq32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c - d) v.AddArg2(v0, x) return true } } break } // match: (Eq32 (Const32 [c]) (Const32 [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Rsh32Ux64 mul:(Hmul32u (Const32 [m]) x) (Const64 [s])) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<31+umagic32(c).m/2) && s == umagic32(c).s-1 && x.Op != OpConst32 && udivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(udivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(32-udivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(udivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpRsh32Ux64 { continue } _ = v_1_1.Args[1] mul := v_1_1.Args[0] if mul.Op != OpHmul32u { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if x != mul_1 { continue } v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<31+umagic32(c).m/2) && s == umagic32(c).s-1 && x.Op != OpConst32 && udivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(udivisible32(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(32 - udivisible32(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(udivisible32(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Rsh32Ux64 mul:(Hmul32u (Const32 <typ.UInt32> [m]) (Rsh32Ux64 x (Const64 [1]))) (Const64 [s])) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<31+(umagic32(c).m+1)/2) && s == umagic32(c).s-2 && x.Op != OpConst32 && udivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(udivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(32-udivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(udivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpRsh32Ux64 { continue } _ = v_1_1.Args[1] mul := v_1_1.Args[0] if mul.Op != OpHmul32u { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 || mul_0.Type != typ.UInt32 { continue } m := auxIntToInt32(mul_0.AuxInt) if mul_1.Op != OpRsh32Ux64 { continue } _ = mul_1.Args[1] if x != mul_1.Args[0] { continue } mul_1_1 := mul_1.Args[1] if mul_1_1.Op != OpConst64 || auxIntToInt64(mul_1_1.AuxInt) != 1 { continue } v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<31+(umagic32(c).m+1)/2) && s == umagic32(c).s-2 && x.Op != OpConst32 && udivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(udivisible32(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(32 - udivisible32(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(udivisible32(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Rsh32Ux64 (Avg32u x mul:(Hmul32u (Const32 [m]) x)) (Const64 [s])) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(umagic32(c).m) && s == umagic32(c).s-1 && x.Op != OpConst32 && udivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(udivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(32-udivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(udivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpRsh32Ux64 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpAvg32u { continue } _ = v_1_1_0.Args[1] if x != v_1_1_0.Args[0] { continue } mul := v_1_1_0.Args[1] if mul.Op != OpHmul32u { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if x != mul_1 { continue } v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(umagic32(c).m) && s == umagic32(c).s-1 && x.Op != OpConst32 && udivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(udivisible32(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(32 - udivisible32(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(udivisible32(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Trunc64to32 (Rsh64Ux64 mul:(Mul64 (Const64 [m]) (ZeroExt32to64 x)) (Const64 [s]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<31+umagic32(c).m/2) && s == 32+umagic32(c).s-1 && x.Op != OpConst32 && udivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(udivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(32-udivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(udivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpTrunc64to32 { continue } v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh64Ux64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul64 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if mul_1.Op != OpZeroExt32to64 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<31+umagic32(c).m/2) && s == 32+umagic32(c).s-1 && x.Op != OpConst32 && udivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(udivisible32(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(32 - udivisible32(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(udivisible32(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Trunc64to32 (Rsh64Ux64 mul:(Mul64 (Const64 [m]) (Rsh64Ux64 (ZeroExt32to64 x) (Const64 [1]))) (Const64 [s]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<31+(umagic32(c).m+1)/2) && s == 32+umagic32(c).s-2 && x.Op != OpConst32 && udivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(udivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(32-udivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(udivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpTrunc64to32 { continue } v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh64Ux64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul64 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if mul_1.Op != OpRsh64Ux64 { continue } _ = mul_1.Args[1] mul_1_0 := mul_1.Args[0] if mul_1_0.Op != OpZeroExt32to64 || x != mul_1_0.Args[0] { continue } mul_1_1 := mul_1.Args[1] if mul_1_1.Op != OpConst64 || auxIntToInt64(mul_1_1.AuxInt) != 1 { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<31+(umagic32(c).m+1)/2) && s == 32+umagic32(c).s-2 && x.Op != OpConst32 && udivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(udivisible32(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(32 - udivisible32(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(udivisible32(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Trunc64to32 (Rsh64Ux64 (Avg64u (Lsh64x64 (ZeroExt32to64 x) (Const64 [32])) mul:(Mul64 (Const64 [m]) (ZeroExt32to64 x))) (Const64 [s]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(umagic32(c).m) && s == 32+umagic32(c).s-1 && x.Op != OpConst32 && udivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(udivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(32-udivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(udivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpTrunc64to32 { continue } v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh64Ux64 { continue } _ = v_1_1_0.Args[1] v_1_1_0_0 := v_1_1_0.Args[0] if v_1_1_0_0.Op != OpAvg64u { continue } _ = v_1_1_0_0.Args[1] v_1_1_0_0_0 := v_1_1_0_0.Args[0] if v_1_1_0_0_0.Op != OpLsh64x64 { continue } _ = v_1_1_0_0_0.Args[1] v_1_1_0_0_0_0 := v_1_1_0_0_0.Args[0] if v_1_1_0_0_0_0.Op != OpZeroExt32to64 || x != v_1_1_0_0_0_0.Args[0] { continue } v_1_1_0_0_0_1 := v_1_1_0_0_0.Args[1] if v_1_1_0_0_0_1.Op != OpConst64 || auxIntToInt64(v_1_1_0_0_0_1.AuxInt) != 32 { continue } mul := v_1_1_0_0.Args[1] if mul.Op != OpMul64 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if mul_1.Op != OpZeroExt32to64 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(umagic32(c).m) && s == 32+umagic32(c).s-1 && x.Op != OpConst32 && udivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(udivisible32(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(32 - udivisible32(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(udivisible32(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Sub32 (Rsh64x64 mul:(Mul64 (Const64 [m]) (SignExt32to64 x)) (Const64 [s])) (Rsh64x64 (SignExt32to64 x) (Const64 [63]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(smagic32(c).m) && s == 32+smagic32(c).s && x.Op != OpConst32 && sdivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Add32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(sdivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(sdivisible32(c).a)]) ) (Const32 <typ.UInt32> [int32(32-sdivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(sdivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpSub32 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh64x64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul64 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if mul_1.Op != OpSignExt32to64 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpRsh64x64 { continue } _ = v_1_1_1.Args[1] v_1_1_1_0 := v_1_1_1.Args[0] if v_1_1_1_0.Op != OpSignExt32to64 || x != v_1_1_1_0.Args[0] { continue } v_1_1_1_1 := v_1_1_1.Args[1] if v_1_1_1_1.Op != OpConst64 || auxIntToInt64(v_1_1_1_1.AuxInt) != 63 || !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(smagic32(c).m) && s == 32+smagic32(c).s && x.Op != OpConst32 && sdivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpAdd32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(sdivisible32(c).m)) v2.AddArg2(v3, x) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(sdivisible32(c).a)) v1.AddArg2(v2, v4) v5 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v5.AuxInt = int32ToAuxInt(int32(32 - sdivisible32(c).k)) v0.AddArg2(v1, v5) v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v6.AuxInt = int32ToAuxInt(int32(sdivisible32(c).max)) v.AddArg2(v0, v6) return true } } } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Sub32 (Rsh32x64 mul:(Hmul32 (Const32 [m]) x) (Const64 [s])) (Rsh32x64 x (Const64 [31]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(smagic32(c).m/2) && s == smagic32(c).s-1 && x.Op != OpConst32 && sdivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Add32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(sdivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(sdivisible32(c).a)]) ) (Const32 <typ.UInt32> [int32(32-sdivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(sdivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpSub32 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh32x64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpHmul32 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if x != mul_1 { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpRsh32x64 { continue } _ = v_1_1_1.Args[1] if x != v_1_1_1.Args[0] { continue } v_1_1_1_1 := v_1_1_1.Args[1] if v_1_1_1_1.Op != OpConst64 || auxIntToInt64(v_1_1_1_1.AuxInt) != 31 || !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(smagic32(c).m/2) && s == smagic32(c).s-1 && x.Op != OpConst32 && sdivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpAdd32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(sdivisible32(c).m)) v2.AddArg2(v3, x) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(sdivisible32(c).a)) v1.AddArg2(v2, v4) v5 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v5.AuxInt = int32ToAuxInt(int32(32 - sdivisible32(c).k)) v0.AddArg2(v1, v5) v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v6.AuxInt = int32ToAuxInt(int32(sdivisible32(c).max)) v.AddArg2(v0, v6) return true } } } break } // match: (Eq32 x (Mul32 (Const32 [c]) (Sub32 (Rsh32x64 (Add32 mul:(Hmul32 (Const32 [m]) x) x) (Const64 [s])) (Rsh32x64 x (Const64 [31]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(smagic32(c).m) && s == smagic32(c).s && x.Op != OpConst32 && sdivisibleOK32(c) // result: (Leq32U (RotateLeft32 <typ.UInt32> (Add32 <typ.UInt32> (Mul32 <typ.UInt32> (Const32 <typ.UInt32> [int32(sdivisible32(c).m)]) x) (Const32 <typ.UInt32> [int32(sdivisible32(c).a)]) ) (Const32 <typ.UInt32> [int32(32-sdivisible32(c).k)]) ) (Const32 <typ.UInt32> [int32(sdivisible32(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 { continue } c := auxIntToInt32(v_1_0.AuxInt) if v_1_1.Op != OpSub32 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh32x64 { continue } _ = v_1_1_0.Args[1] v_1_1_0_0 := v_1_1_0.Args[0] if v_1_1_0_0.Op != OpAdd32 { continue } _ = v_1_1_0_0.Args[1] v_1_1_0_0_0 := v_1_1_0_0.Args[0] v_1_1_0_0_1 := v_1_1_0_0.Args[1] for _i2 := 0; _i2 <= 1; _i2, v_1_1_0_0_0, v_1_1_0_0_1 = _i2+1, v_1_1_0_0_1, v_1_1_0_0_0 { mul := v_1_1_0_0_0 if mul.Op != OpHmul32 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i3 := 0; _i3 <= 1; _i3, mul_0, mul_1 = _i3+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if x != mul_1 || x != v_1_1_0_0_1 { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpRsh32x64 { continue } _ = v_1_1_1.Args[1] if x != v_1_1_1.Args[0] { continue } v_1_1_1_1 := v_1_1_1.Args[1] if v_1_1_1_1.Op != OpConst64 || auxIntToInt64(v_1_1_1_1.AuxInt) != 31 || !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(smagic32(c).m) && s == smagic32(c).s && x.Op != OpConst32 && sdivisibleOK32(c)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpRotateLeft32, typ.UInt32) v1 := b.NewValue0(v.Pos, OpAdd32, typ.UInt32) v2 := b.NewValue0(v.Pos, OpMul32, typ.UInt32) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(int32(sdivisible32(c).m)) v2.AddArg2(v3, x) v4 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v4.AuxInt = int32ToAuxInt(int32(sdivisible32(c).a)) v1.AddArg2(v2, v4) v5 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v5.AuxInt = int32ToAuxInt(int32(32 - sdivisible32(c).k)) v0.AddArg2(v1, v5) v6 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v6.AuxInt = int32ToAuxInt(int32(sdivisible32(c).max)) v.AddArg2(v0, v6) return true } } } } break } // match: (Eq32 n (Lsh32x64 (Rsh32x64 (Add32 <t> n (Rsh32Ux64 <t> (Rsh32x64 <t> n (Const64 <typ.UInt64> [31])) (Const64 <typ.UInt64> [kbar]))) (Const64 <typ.UInt64> [k])) (Const64 <typ.UInt64> [k])) ) // cond: k > 0 && k < 31 && kbar == 32 - k // result: (Eq32 (And32 <t> n (Const32 <t> [1<<uint(k)-1])) (Const32 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpLsh32x64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpRsh32x64 { continue } _ = v_1_0.Args[1] v_1_0_0 := v_1_0.Args[0] if v_1_0_0.Op != OpAdd32 { continue } t := v_1_0_0.Type _ = v_1_0_0.Args[1] v_1_0_0_0 := v_1_0_0.Args[0] v_1_0_0_1 := v_1_0_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0_0_0, v_1_0_0_1 = _i1+1, v_1_0_0_1, v_1_0_0_0 { if n != v_1_0_0_0 || v_1_0_0_1.Op != OpRsh32Ux64 || v_1_0_0_1.Type != t { continue } _ = v_1_0_0_1.Args[1] v_1_0_0_1_0 := v_1_0_0_1.Args[0] if v_1_0_0_1_0.Op != OpRsh32x64 || v_1_0_0_1_0.Type != t { continue } _ = v_1_0_0_1_0.Args[1] if n != v_1_0_0_1_0.Args[0] { continue } v_1_0_0_1_0_1 := v_1_0_0_1_0.Args[1] if v_1_0_0_1_0_1.Op != OpConst64 || v_1_0_0_1_0_1.Type != typ.UInt64 || auxIntToInt64(v_1_0_0_1_0_1.AuxInt) != 31 { continue } v_1_0_0_1_1 := v_1_0_0_1.Args[1] if v_1_0_0_1_1.Op != OpConst64 || v_1_0_0_1_1.Type != typ.UInt64 { continue } kbar := auxIntToInt64(v_1_0_0_1_1.AuxInt) v_1_0_1 := v_1_0.Args[1] if v_1_0_1.Op != OpConst64 || v_1_0_1.Type != typ.UInt64 { continue } k := auxIntToInt64(v_1_0_1.AuxInt) v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != typ.UInt64 || auxIntToInt64(v_1_1.AuxInt) != k || !(k > 0 && k < 31 && kbar == 32-k) { continue } v.reset(OpEq32) v0 := b.NewValue0(v.Pos, OpAnd32, t) v1 := b.NewValue0(v.Pos, OpConst32, t) v1.AuxInt = int32ToAuxInt(1<<uint(k) - 1) v0.AddArg2(n, v1) v2 := b.NewValue0(v.Pos, OpConst32, t) v2.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } // match: (Eq32 s:(Sub32 x y) (Const32 [0])) // cond: s.Uses == 1 // result: (Eq32 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { s := v_0 if s.Op != OpSub32 { continue } y := s.Args[1] x := s.Args[0] if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 || !(s.Uses == 1) { continue } v.reset(OpEq32) v.AddArg2(x, y) return true } break } // match: (Eq32 (And32 <t> x (Const32 <t> [y])) (Const32 <t> [y])) // cond: oneBit32(y) // result: (Neq32 (And32 <t> x (Const32 <t> [y])) (Const32 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd32 { continue } t := v_0.Type _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst32 || v_0_1.Type != t { continue } y := auxIntToInt32(v_0_1.AuxInt) if v_1.Op != OpConst32 || v_1.Type != t || auxIntToInt32(v_1.AuxInt) != y || !(oneBit32(y)) { continue } v.reset(OpNeq32) v0 := b.NewValue0(v.Pos, OpAnd32, t) v1 := b.NewValue0(v.Pos, OpConst32, t) v1.AuxInt = int32ToAuxInt(y) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, t) v2.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } return false } func rewriteValuegeneric_OpEq32F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Eq32F (Const32F [c]) (Const32F [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32F { continue } c := auxIntToFloat32(v_0.AuxInt) if v_1.Op != OpConst32F { continue } d := auxIntToFloat32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } return false } func rewriteValuegeneric_OpEq64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Eq64 x x) // result: (ConstBool [true]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (Eq64 (Const64 <t> [c]) (Add64 (Const64 <t> [d]) x)) // result: (Eq64 (Const64 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpAdd64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 v.reset(OpEq64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c - d) v.AddArg2(v0, x) return true } } break } // match: (Eq64 (Const64 [c]) (Const64 [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } // match: (Eq64 x (Mul64 (Const64 [c]) (Rsh64Ux64 mul:(Hmul64u (Const64 [m]) x) (Const64 [s])) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<63+umagic64(c).m/2) && s == umagic64(c).s-1 && x.Op != OpConst64 && udivisibleOK64(c) // result: (Leq64U (RotateLeft64 <typ.UInt64> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(udivisible64(c).m)]) x) (Const64 <typ.UInt64> [64-udivisible64(c).k]) ) (Const64 <typ.UInt64> [int64(udivisible64(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 { continue } c := auxIntToInt64(v_1_0.AuxInt) if v_1_1.Op != OpRsh64Ux64 { continue } _ = v_1_1.Args[1] mul := v_1_1.Args[0] if mul.Op != OpHmul64u { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if x != mul_1 { continue } v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<63+umagic64(c).m/2) && s == umagic64(c).s-1 && x.Op != OpConst64 && udivisibleOK64(c)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpRotateLeft64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(udivisible64(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(64 - udivisible64(c).k) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(udivisible64(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq64 x (Mul64 (Const64 [c]) (Rsh64Ux64 mul:(Hmul64u (Const64 [m]) (Rsh64Ux64 x (Const64 [1]))) (Const64 [s])) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<63+(umagic64(c).m+1)/2) && s == umagic64(c).s-2 && x.Op != OpConst64 && udivisibleOK64(c) // result: (Leq64U (RotateLeft64 <typ.UInt64> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(udivisible64(c).m)]) x) (Const64 <typ.UInt64> [64-udivisible64(c).k]) ) (Const64 <typ.UInt64> [int64(udivisible64(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 { continue } c := auxIntToInt64(v_1_0.AuxInt) if v_1_1.Op != OpRsh64Ux64 { continue } _ = v_1_1.Args[1] mul := v_1_1.Args[0] if mul.Op != OpHmul64u { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if mul_1.Op != OpRsh64Ux64 { continue } _ = mul_1.Args[1] if x != mul_1.Args[0] { continue } mul_1_1 := mul_1.Args[1] if mul_1_1.Op != OpConst64 || auxIntToInt64(mul_1_1.AuxInt) != 1 { continue } v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(1<<63+(umagic64(c).m+1)/2) && s == umagic64(c).s-2 && x.Op != OpConst64 && udivisibleOK64(c)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpRotateLeft64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(udivisible64(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(64 - udivisible64(c).k) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(udivisible64(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq64 x (Mul64 (Const64 [c]) (Rsh64Ux64 (Avg64u x mul:(Hmul64u (Const64 [m]) x)) (Const64 [s])) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(umagic64(c).m) && s == umagic64(c).s-1 && x.Op != OpConst64 && udivisibleOK64(c) // result: (Leq64U (RotateLeft64 <typ.UInt64> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(udivisible64(c).m)]) x) (Const64 <typ.UInt64> [64-udivisible64(c).k]) ) (Const64 <typ.UInt64> [int64(udivisible64(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 { continue } c := auxIntToInt64(v_1_0.AuxInt) if v_1_1.Op != OpRsh64Ux64 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpAvg64u { continue } _ = v_1_1_0.Args[1] if x != v_1_1_0.Args[0] { continue } mul := v_1_1_0.Args[1] if mul.Op != OpHmul64u { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if x != mul_1 { continue } v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(umagic64(c).m) && s == umagic64(c).s-1 && x.Op != OpConst64 && udivisibleOK64(c)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpRotateLeft64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v2.AuxInt = int64ToAuxInt(int64(udivisible64(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(64 - udivisible64(c).k) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(udivisible64(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq64 x (Mul64 (Const64 [c]) (Sub64 (Rsh64x64 mul:(Hmul64 (Const64 [m]) x) (Const64 [s])) (Rsh64x64 x (Const64 [63]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(smagic64(c).m/2) && s == smagic64(c).s-1 && x.Op != OpConst64 && sdivisibleOK64(c) // result: (Leq64U (RotateLeft64 <typ.UInt64> (Add64 <typ.UInt64> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(sdivisible64(c).m)]) x) (Const64 <typ.UInt64> [int64(sdivisible64(c).a)]) ) (Const64 <typ.UInt64> [64-sdivisible64(c).k]) ) (Const64 <typ.UInt64> [int64(sdivisible64(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 { continue } c := auxIntToInt64(v_1_0.AuxInt) if v_1_1.Op != OpSub64 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh64x64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpHmul64 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if x != mul_1 { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpRsh64x64 { continue } _ = v_1_1_1.Args[1] if x != v_1_1_1.Args[0] { continue } v_1_1_1_1 := v_1_1_1.Args[1] if v_1_1_1_1.Op != OpConst64 || auxIntToInt64(v_1_1_1_1.AuxInt) != 63 || !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(smagic64(c).m/2) && s == smagic64(c).s-1 && x.Op != OpConst64 && sdivisibleOK64(c)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpRotateLeft64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpAdd64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(int64(sdivisible64(c).m)) v2.AddArg2(v3, x) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(sdivisible64(c).a)) v1.AddArg2(v2, v4) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(64 - sdivisible64(c).k) v0.AddArg2(v1, v5) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(int64(sdivisible64(c).max)) v.AddArg2(v0, v6) return true } } } break } // match: (Eq64 x (Mul64 (Const64 [c]) (Sub64 (Rsh64x64 (Add64 mul:(Hmul64 (Const64 [m]) x) x) (Const64 [s])) (Rsh64x64 x (Const64 [63]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(smagic64(c).m) && s == smagic64(c).s && x.Op != OpConst64 && sdivisibleOK64(c) // result: (Leq64U (RotateLeft64 <typ.UInt64> (Add64 <typ.UInt64> (Mul64 <typ.UInt64> (Const64 <typ.UInt64> [int64(sdivisible64(c).m)]) x) (Const64 <typ.UInt64> [int64(sdivisible64(c).a)]) ) (Const64 <typ.UInt64> [64-sdivisible64(c).k]) ) (Const64 <typ.UInt64> [int64(sdivisible64(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 { continue } c := auxIntToInt64(v_1_0.AuxInt) if v_1_1.Op != OpSub64 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh64x64 { continue } _ = v_1_1_0.Args[1] v_1_1_0_0 := v_1_1_0.Args[0] if v_1_1_0_0.Op != OpAdd64 { continue } _ = v_1_1_0_0.Args[1] v_1_1_0_0_0 := v_1_1_0_0.Args[0] v_1_1_0_0_1 := v_1_1_0_0.Args[1] for _i2 := 0; _i2 <= 1; _i2, v_1_1_0_0_0, v_1_1_0_0_1 = _i2+1, v_1_1_0_0_1, v_1_1_0_0_0 { mul := v_1_1_0_0_0 if mul.Op != OpHmul64 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i3 := 0; _i3 <= 1; _i3, mul_0, mul_1 = _i3+1, mul_1, mul_0 { if mul_0.Op != OpConst64 { continue } m := auxIntToInt64(mul_0.AuxInt) if x != mul_1 || x != v_1_1_0_0_1 { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpRsh64x64 { continue } _ = v_1_1_1.Args[1] if x != v_1_1_1.Args[0] { continue } v_1_1_1_1 := v_1_1_1.Args[1] if v_1_1_1_1.Op != OpConst64 || auxIntToInt64(v_1_1_1_1.AuxInt) != 63 || !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int64(smagic64(c).m) && s == smagic64(c).s && x.Op != OpConst64 && sdivisibleOK64(c)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpRotateLeft64, typ.UInt64) v1 := b.NewValue0(v.Pos, OpAdd64, typ.UInt64) v2 := b.NewValue0(v.Pos, OpMul64, typ.UInt64) v3 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v3.AuxInt = int64ToAuxInt(int64(sdivisible64(c).m)) v2.AddArg2(v3, x) v4 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v4.AuxInt = int64ToAuxInt(int64(sdivisible64(c).a)) v1.AddArg2(v2, v4) v5 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v5.AuxInt = int64ToAuxInt(64 - sdivisible64(c).k) v0.AddArg2(v1, v5) v6 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v6.AuxInt = int64ToAuxInt(int64(sdivisible64(c).max)) v.AddArg2(v0, v6) return true } } } } break } // match: (Eq64 n (Lsh64x64 (Rsh64x64 (Add64 <t> n (Rsh64Ux64 <t> (Rsh64x64 <t> n (Const64 <typ.UInt64> [63])) (Const64 <typ.UInt64> [kbar]))) (Const64 <typ.UInt64> [k])) (Const64 <typ.UInt64> [k])) ) // cond: k > 0 && k < 63 && kbar == 64 - k // result: (Eq64 (And64 <t> n (Const64 <t> [1<<uint(k)-1])) (Const64 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpLsh64x64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpRsh64x64 { continue } _ = v_1_0.Args[1] v_1_0_0 := v_1_0.Args[0] if v_1_0_0.Op != OpAdd64 { continue } t := v_1_0_0.Type _ = v_1_0_0.Args[1] v_1_0_0_0 := v_1_0_0.Args[0] v_1_0_0_1 := v_1_0_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0_0_0, v_1_0_0_1 = _i1+1, v_1_0_0_1, v_1_0_0_0 { if n != v_1_0_0_0 || v_1_0_0_1.Op != OpRsh64Ux64 || v_1_0_0_1.Type != t { continue } _ = v_1_0_0_1.Args[1] v_1_0_0_1_0 := v_1_0_0_1.Args[0] if v_1_0_0_1_0.Op != OpRsh64x64 || v_1_0_0_1_0.Type != t { continue } _ = v_1_0_0_1_0.Args[1] if n != v_1_0_0_1_0.Args[0] { continue } v_1_0_0_1_0_1 := v_1_0_0_1_0.Args[1] if v_1_0_0_1_0_1.Op != OpConst64 || v_1_0_0_1_0_1.Type != typ.UInt64 || auxIntToInt64(v_1_0_0_1_0_1.AuxInt) != 63 { continue } v_1_0_0_1_1 := v_1_0_0_1.Args[1] if v_1_0_0_1_1.Op != OpConst64 || v_1_0_0_1_1.Type != typ.UInt64 { continue } kbar := auxIntToInt64(v_1_0_0_1_1.AuxInt) v_1_0_1 := v_1_0.Args[1] if v_1_0_1.Op != OpConst64 || v_1_0_1.Type != typ.UInt64 { continue } k := auxIntToInt64(v_1_0_1.AuxInt) v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != typ.UInt64 || auxIntToInt64(v_1_1.AuxInt) != k || !(k > 0 && k < 63 && kbar == 64-k) { continue } v.reset(OpEq64) v0 := b.NewValue0(v.Pos, OpAnd64, t) v1 := b.NewValue0(v.Pos, OpConst64, t) v1.AuxInt = int64ToAuxInt(1<<uint(k) - 1) v0.AddArg2(n, v1) v2 := b.NewValue0(v.Pos, OpConst64, t) v2.AuxInt = int64ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } // match: (Eq64 s:(Sub64 x y) (Const64 [0])) // cond: s.Uses == 1 // result: (Eq64 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { s := v_0 if s.Op != OpSub64 { continue } y := s.Args[1] x := s.Args[0] if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 || !(s.Uses == 1) { continue } v.reset(OpEq64) v.AddArg2(x, y) return true } break } // match: (Eq64 (And64 <t> x (Const64 <t> [y])) (Const64 <t> [y])) // cond: oneBit64(y) // result: (Neq64 (And64 <t> x (Const64 <t> [y])) (Const64 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd64 { continue } t := v_0.Type _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst64 || v_0_1.Type != t { continue } y := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 || v_1.Type != t || auxIntToInt64(v_1.AuxInt) != y || !(oneBit64(y)) { continue } v.reset(OpNeq64) v0 := b.NewValue0(v.Pos, OpAnd64, t) v1 := b.NewValue0(v.Pos, OpConst64, t) v1.AuxInt = int64ToAuxInt(y) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, t) v2.AuxInt = int64ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } return false } func rewriteValuegeneric_OpEq64F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Eq64F (Const64F [c]) (Const64F [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64F { continue } c := auxIntToFloat64(v_0.AuxInt) if v_1.Op != OpConst64F { continue } d := auxIntToFloat64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } return false } func rewriteValuegeneric_OpEq8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (Eq8 x x) // result: (ConstBool [true]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (Eq8 (Const8 <t> [c]) (Add8 (Const8 <t> [d]) x)) // result: (Eq8 (Const8 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpAdd8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 || v_1_0.Type != t { continue } d := auxIntToInt8(v_1_0.AuxInt) x := v_1_1 v.reset(OpEq8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c - d) v.AddArg2(v0, x) return true } } break } // match: (Eq8 (Const8 [c]) (Const8 [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } // match: (Eq8 (Mod8u x (Const8 [c])) (Const8 [0])) // cond: x.Op != OpConst8 && udivisibleOK8(c) && !hasSmallRotate(config) // result: (Eq32 (Mod32u <typ.UInt32> (ZeroExt8to32 <typ.UInt32> x) (Const32 <typ.UInt32> [int32(uint8(c))])) (Const32 <typ.UInt32> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpMod8u { continue } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst8 { continue } c := auxIntToInt8(v_0_1.AuxInt) if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 || !(x.Op != OpConst8 && udivisibleOK8(c) && !hasSmallRotate(config)) { continue } v.reset(OpEq32) v0 := b.NewValue0(v.Pos, OpMod32u, typ.UInt32) v1 := b.NewValue0(v.Pos, OpZeroExt8to32, typ.UInt32) v1.AddArg(x) v2 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v2.AuxInt = int32ToAuxInt(int32(uint8(c))) v0.AddArg2(v1, v2) v3 := b.NewValue0(v.Pos, OpConst32, typ.UInt32) v3.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v3) return true } break } // match: (Eq8 (Mod8 x (Const8 [c])) (Const8 [0])) // cond: x.Op != OpConst8 && sdivisibleOK8(c) && !hasSmallRotate(config) // result: (Eq32 (Mod32 <typ.Int32> (SignExt8to32 <typ.Int32> x) (Const32 <typ.Int32> [int32(c)])) (Const32 <typ.Int32> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpMod8 { continue } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst8 { continue } c := auxIntToInt8(v_0_1.AuxInt) if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 || !(x.Op != OpConst8 && sdivisibleOK8(c) && !hasSmallRotate(config)) { continue } v.reset(OpEq32) v0 := b.NewValue0(v.Pos, OpMod32, typ.Int32) v1 := b.NewValue0(v.Pos, OpSignExt8to32, typ.Int32) v1.AddArg(x) v2 := b.NewValue0(v.Pos, OpConst32, typ.Int32) v2.AuxInt = int32ToAuxInt(int32(c)) v0.AddArg2(v1, v2) v3 := b.NewValue0(v.Pos, OpConst32, typ.Int32) v3.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v3) return true } break } // match: (Eq8 x (Mul8 (Const8 [c]) (Trunc32to8 (Rsh32Ux64 mul:(Mul32 (Const32 [m]) (ZeroExt8to32 x)) (Const64 [s]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<8+umagic8(c).m) && s == 8+umagic8(c).s && x.Op != OpConst8 && udivisibleOK8(c) // result: (Leq8U (RotateLeft8 <typ.UInt8> (Mul8 <typ.UInt8> (Const8 <typ.UInt8> [int8(udivisible8(c).m)]) x) (Const8 <typ.UInt8> [int8(8-udivisible8(c).k)]) ) (Const8 <typ.UInt8> [int8(udivisible8(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 { continue } c := auxIntToInt8(v_1_0.AuxInt) if v_1_1.Op != OpTrunc32to8 { continue } v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh32Ux64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul32 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if mul_1.Op != OpZeroExt8to32 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) if !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(1<<8+umagic8(c).m) && s == 8+umagic8(c).s && x.Op != OpConst8 && udivisibleOK8(c)) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpRotateLeft8, typ.UInt8) v1 := b.NewValue0(v.Pos, OpMul8, typ.UInt8) v2 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) v2.AuxInt = int8ToAuxInt(int8(udivisible8(c).m)) v1.AddArg2(v2, x) v3 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) v3.AuxInt = int8ToAuxInt(int8(8 - udivisible8(c).k)) v0.AddArg2(v1, v3) v4 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) v4.AuxInt = int8ToAuxInt(int8(udivisible8(c).max)) v.AddArg2(v0, v4) return true } } } break } // match: (Eq8 x (Mul8 (Const8 [c]) (Sub8 (Rsh32x64 mul:(Mul32 (Const32 [m]) (SignExt8to32 x)) (Const64 [s])) (Rsh32x64 (SignExt8to32 x) (Const64 [31]))) ) ) // cond: v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(smagic8(c).m) && s == 8+smagic8(c).s && x.Op != OpConst8 && sdivisibleOK8(c) // result: (Leq8U (RotateLeft8 <typ.UInt8> (Add8 <typ.UInt8> (Mul8 <typ.UInt8> (Const8 <typ.UInt8> [int8(sdivisible8(c).m)]) x) (Const8 <typ.UInt8> [int8(sdivisible8(c).a)]) ) (Const8 <typ.UInt8> [int8(8-sdivisible8(c).k)]) ) (Const8 <typ.UInt8> [int8(sdivisible8(c).max)]) ) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpMul8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 { continue } c := auxIntToInt8(v_1_0.AuxInt) if v_1_1.Op != OpSub8 { continue } _ = v_1_1.Args[1] v_1_1_0 := v_1_1.Args[0] if v_1_1_0.Op != OpRsh32x64 { continue } _ = v_1_1_0.Args[1] mul := v_1_1_0.Args[0] if mul.Op != OpMul32 { continue } _ = mul.Args[1] mul_0 := mul.Args[0] mul_1 := mul.Args[1] for _i2 := 0; _i2 <= 1; _i2, mul_0, mul_1 = _i2+1, mul_1, mul_0 { if mul_0.Op != OpConst32 { continue } m := auxIntToInt32(mul_0.AuxInt) if mul_1.Op != OpSignExt8to32 || x != mul_1.Args[0] { continue } v_1_1_0_1 := v_1_1_0.Args[1] if v_1_1_0_1.Op != OpConst64 { continue } s := auxIntToInt64(v_1_1_0_1.AuxInt) v_1_1_1 := v_1_1.Args[1] if v_1_1_1.Op != OpRsh32x64 { continue } _ = v_1_1_1.Args[1] v_1_1_1_0 := v_1_1_1.Args[0] if v_1_1_1_0.Op != OpSignExt8to32 || x != v_1_1_1_0.Args[0] { continue } v_1_1_1_1 := v_1_1_1.Args[1] if v_1_1_1_1.Op != OpConst64 || auxIntToInt64(v_1_1_1_1.AuxInt) != 31 || !(v.Block.Func.pass.name != "opt" && mul.Uses == 1 && m == int32(smagic8(c).m) && s == 8+smagic8(c).s && x.Op != OpConst8 && sdivisibleOK8(c)) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpRotateLeft8, typ.UInt8) v1 := b.NewValue0(v.Pos, OpAdd8, typ.UInt8) v2 := b.NewValue0(v.Pos, OpMul8, typ.UInt8) v3 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) v3.AuxInt = int8ToAuxInt(int8(sdivisible8(c).m)) v2.AddArg2(v3, x) v4 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) v4.AuxInt = int8ToAuxInt(int8(sdivisible8(c).a)) v1.AddArg2(v2, v4) v5 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) v5.AuxInt = int8ToAuxInt(int8(8 - sdivisible8(c).k)) v0.AddArg2(v1, v5) v6 := b.NewValue0(v.Pos, OpConst8, typ.UInt8) v6.AuxInt = int8ToAuxInt(int8(sdivisible8(c).max)) v.AddArg2(v0, v6) return true } } } break } // match: (Eq8 n (Lsh8x64 (Rsh8x64 (Add8 <t> n (Rsh8Ux64 <t> (Rsh8x64 <t> n (Const64 <typ.UInt64> [ 7])) (Const64 <typ.UInt64> [kbar]))) (Const64 <typ.UInt64> [k])) (Const64 <typ.UInt64> [k])) ) // cond: k > 0 && k < 7 && kbar == 8 - k // result: (Eq8 (And8 <t> n (Const8 <t> [1<<uint(k)-1])) (Const8 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpLsh8x64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpRsh8x64 { continue } _ = v_1_0.Args[1] v_1_0_0 := v_1_0.Args[0] if v_1_0_0.Op != OpAdd8 { continue } t := v_1_0_0.Type _ = v_1_0_0.Args[1] v_1_0_0_0 := v_1_0_0.Args[0] v_1_0_0_1 := v_1_0_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0_0_0, v_1_0_0_1 = _i1+1, v_1_0_0_1, v_1_0_0_0 { if n != v_1_0_0_0 || v_1_0_0_1.Op != OpRsh8Ux64 || v_1_0_0_1.Type != t { continue } _ = v_1_0_0_1.Args[1] v_1_0_0_1_0 := v_1_0_0_1.Args[0] if v_1_0_0_1_0.Op != OpRsh8x64 || v_1_0_0_1_0.Type != t { continue } _ = v_1_0_0_1_0.Args[1] if n != v_1_0_0_1_0.Args[0] { continue } v_1_0_0_1_0_1 := v_1_0_0_1_0.Args[1] if v_1_0_0_1_0_1.Op != OpConst64 || v_1_0_0_1_0_1.Type != typ.UInt64 || auxIntToInt64(v_1_0_0_1_0_1.AuxInt) != 7 { continue } v_1_0_0_1_1 := v_1_0_0_1.Args[1] if v_1_0_0_1_1.Op != OpConst64 || v_1_0_0_1_1.Type != typ.UInt64 { continue } kbar := auxIntToInt64(v_1_0_0_1_1.AuxInt) v_1_0_1 := v_1_0.Args[1] if v_1_0_1.Op != OpConst64 || v_1_0_1.Type != typ.UInt64 { continue } k := auxIntToInt64(v_1_0_1.AuxInt) v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != typ.UInt64 || auxIntToInt64(v_1_1.AuxInt) != k || !(k > 0 && k < 7 && kbar == 8-k) { continue } v.reset(OpEq8) v0 := b.NewValue0(v.Pos, OpAnd8, t) v1 := b.NewValue0(v.Pos, OpConst8, t) v1.AuxInt = int8ToAuxInt(1<<uint(k) - 1) v0.AddArg2(n, v1) v2 := b.NewValue0(v.Pos, OpConst8, t) v2.AuxInt = int8ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } // match: (Eq8 s:(Sub8 x y) (Const8 [0])) // cond: s.Uses == 1 // result: (Eq8 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { s := v_0 if s.Op != OpSub8 { continue } y := s.Args[1] x := s.Args[0] if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 || !(s.Uses == 1) { continue } v.reset(OpEq8) v.AddArg2(x, y) return true } break } // match: (Eq8 (And8 <t> x (Const8 <t> [y])) (Const8 <t> [y])) // cond: oneBit8(y) // result: (Neq8 (And8 <t> x (Const8 <t> [y])) (Const8 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd8 { continue } t := v_0.Type _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst8 || v_0_1.Type != t { continue } y := auxIntToInt8(v_0_1.AuxInt) if v_1.Op != OpConst8 || v_1.Type != t || auxIntToInt8(v_1.AuxInt) != y || !(oneBit8(y)) { continue } v.reset(OpNeq8) v0 := b.NewValue0(v.Pos, OpAnd8, t) v1 := b.NewValue0(v.Pos, OpConst8, t) v1.AuxInt = int8ToAuxInt(y) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, t) v2.AuxInt = int8ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } return false } func rewriteValuegeneric_OpEqB(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (EqB (ConstBool [c]) (ConstBool [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConstBool { continue } c := auxIntToBool(v_0.AuxInt) if v_1.Op != OpConstBool { continue } d := auxIntToBool(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } // match: (EqB (ConstBool [false]) x) // result: (Not x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != false { continue } x := v_1 v.reset(OpNot) v.AddArg(x) return true } break } // match: (EqB (ConstBool [true]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != true { continue } x := v_1 v.copyOf(x) return true } break } return false } func rewriteValuegeneric_OpEqInter(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (EqInter x y) // result: (EqPtr (ITab x) (ITab y)) for { x := v_0 y := v_1 v.reset(OpEqPtr) v0 := b.NewValue0(v.Pos, OpITab, typ.Uintptr) v0.AddArg(x) v1 := b.NewValue0(v.Pos, OpITab, typ.Uintptr) v1.AddArg(y) v.AddArg2(v0, v1) return true } } func rewriteValuegeneric_OpEqPtr(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (EqPtr x x) // result: (ConstBool [true]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (EqPtr (Addr {a} _) (Addr {b} _)) // result: (ConstBool [a == b]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAddr { continue } a := auxToSym(v_0.Aux) if v_1.Op != OpAddr { continue } b := auxToSym(v_1.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a == b) return true } break } // match: (EqPtr (Addr {a} _) (OffPtr [o] (Addr {b} _))) // result: (ConstBool [a == b && o == 0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAddr { continue } a := auxToSym(v_0.Aux) if v_1.Op != OpOffPtr { continue } o := auxIntToInt64(v_1.AuxInt) v_1_0 := v_1.Args[0] if v_1_0.Op != OpAddr { continue } b := auxToSym(v_1_0.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a == b && o == 0) return true } break } // match: (EqPtr (OffPtr [o1] (Addr {a} _)) (OffPtr [o2] (Addr {b} _))) // result: (ConstBool [a == b && o1 == o2]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } o1 := auxIntToInt64(v_0.AuxInt) v_0_0 := v_0.Args[0] if v_0_0.Op != OpAddr { continue } a := auxToSym(v_0_0.Aux) if v_1.Op != OpOffPtr { continue } o2 := auxIntToInt64(v_1.AuxInt) v_1_0 := v_1.Args[0] if v_1_0.Op != OpAddr { continue } b := auxToSym(v_1_0.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a == b && o1 == o2) return true } break } // match: (EqPtr (LocalAddr {a} _ _) (LocalAddr {b} _ _)) // result: (ConstBool [a == b]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLocalAddr { continue } a := auxToSym(v_0.Aux) if v_1.Op != OpLocalAddr { continue } b := auxToSym(v_1.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a == b) return true } break } // match: (EqPtr (LocalAddr {a} _ _) (OffPtr [o] (LocalAddr {b} _ _))) // result: (ConstBool [a == b && o == 0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLocalAddr { continue } a := auxToSym(v_0.Aux) if v_1.Op != OpOffPtr { continue } o := auxIntToInt64(v_1.AuxInt) v_1_0 := v_1.Args[0] if v_1_0.Op != OpLocalAddr { continue } b := auxToSym(v_1_0.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a == b && o == 0) return true } break } // match: (EqPtr (OffPtr [o1] (LocalAddr {a} _ _)) (OffPtr [o2] (LocalAddr {b} _ _))) // result: (ConstBool [a == b && o1 == o2]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } o1 := auxIntToInt64(v_0.AuxInt) v_0_0 := v_0.Args[0] if v_0_0.Op != OpLocalAddr { continue } a := auxToSym(v_0_0.Aux) if v_1.Op != OpOffPtr { continue } o2 := auxIntToInt64(v_1.AuxInt) v_1_0 := v_1.Args[0] if v_1_0.Op != OpLocalAddr { continue } b := auxToSym(v_1_0.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a == b && o1 == o2) return true } break } // match: (EqPtr (OffPtr [o1] p1) p2) // cond: isSamePtr(p1, p2) // result: (ConstBool [o1 == 0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } o1 := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] p2 := v_1 if !(isSamePtr(p1, p2)) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(o1 == 0) return true } break } // match: (EqPtr (OffPtr [o1] p1) (OffPtr [o2] p2)) // cond: isSamePtr(p1, p2) // result: (ConstBool [o1 == o2]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } o1 := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpOffPtr { continue } o2 := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(isSamePtr(p1, p2)) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(o1 == o2) return true } break } // match: (EqPtr (Const32 [c]) (Const32 [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } // match: (EqPtr (Const64 [c]) (Const64 [d])) // result: (ConstBool [c == d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c == d) return true } break } // match: (EqPtr (LocalAddr _ _) (Addr _)) // result: (ConstBool [false]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLocalAddr || v_1.Op != OpAddr { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } break } // match: (EqPtr (OffPtr (LocalAddr _ _)) (Addr _)) // result: (ConstBool [false]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } v_0_0 := v_0.Args[0] if v_0_0.Op != OpLocalAddr || v_1.Op != OpAddr { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } break } // match: (EqPtr (LocalAddr _ _) (OffPtr (Addr _))) // result: (ConstBool [false]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLocalAddr || v_1.Op != OpOffPtr { continue } v_1_0 := v_1.Args[0] if v_1_0.Op != OpAddr { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } break } // match: (EqPtr (OffPtr (LocalAddr _ _)) (OffPtr (Addr _))) // result: (ConstBool [false]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } v_0_0 := v_0.Args[0] if v_0_0.Op != OpLocalAddr || v_1.Op != OpOffPtr { continue } v_1_0 := v_1.Args[0] if v_1_0.Op != OpAddr { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } break } // match: (EqPtr (AddPtr p1 o1) p2) // cond: isSamePtr(p1, p2) // result: (Not (IsNonNil o1)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAddPtr { continue } o1 := v_0.Args[1] p1 := v_0.Args[0] p2 := v_1 if !(isSamePtr(p1, p2)) { continue } v.reset(OpNot) v0 := b.NewValue0(v.Pos, OpIsNonNil, typ.Bool) v0.AddArg(o1) v.AddArg(v0) return true } break } // match: (EqPtr (Const32 [0]) p) // result: (Not (IsNonNil p)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { continue } p := v_1 v.reset(OpNot) v0 := b.NewValue0(v.Pos, OpIsNonNil, typ.Bool) v0.AddArg(p) v.AddArg(v0) return true } break } // match: (EqPtr (Const64 [0]) p) // result: (Not (IsNonNil p)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { continue } p := v_1 v.reset(OpNot) v0 := b.NewValue0(v.Pos, OpIsNonNil, typ.Bool) v0.AddArg(p) v.AddArg(v0) return true } break } // match: (EqPtr (ConstNil) p) // result: (Not (IsNonNil p)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConstNil { continue } p := v_1 v.reset(OpNot) v0 := b.NewValue0(v.Pos, OpIsNonNil, typ.Bool) v0.AddArg(p) v.AddArg(v0) return true } break } return false } func rewriteValuegeneric_OpEqSlice(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (EqSlice x y) // result: (EqPtr (SlicePtr x) (SlicePtr y)) for { x := v_0 y := v_1 v.reset(OpEqPtr) v0 := b.NewValue0(v.Pos, OpSlicePtr, typ.BytePtr) v0.AddArg(x) v1 := b.NewValue0(v.Pos, OpSlicePtr, typ.BytePtr) v1.AddArg(y) v.AddArg2(v0, v1) return true } } func rewriteValuegeneric_OpIMake(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (IMake typ (StructMake1 val)) // result: (IMake typ val) for { typ := v_0 if v_1.Op != OpStructMake1 { break } val := v_1.Args[0] v.reset(OpIMake) v.AddArg2(typ, val) return true } // match: (IMake typ (ArrayMake1 val)) // result: (IMake typ val) for { typ := v_0 if v_1.Op != OpArrayMake1 { break } val := v_1.Args[0] v.reset(OpIMake) v.AddArg2(typ, val) return true } return false } func rewriteValuegeneric_OpInterCall(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (InterCall [argsize] (Load (OffPtr [off] (ITab (IMake (Addr {itab} (SB)) _))) _) mem) // cond: devirt(v, itab, off) != nil // result: (StaticCall [int32(argsize)] {devirt(v, itab, off)} mem) for { argsize := auxIntToInt64(v.AuxInt) if v_0.Op != OpLoad { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpOffPtr { break } off := auxIntToInt64(v_0_0.AuxInt) v_0_0_0 := v_0_0.Args[0] if v_0_0_0.Op != OpITab { break } v_0_0_0_0 := v_0_0_0.Args[0] if v_0_0_0_0.Op != OpIMake { break } v_0_0_0_0_0 := v_0_0_0_0.Args[0] if v_0_0_0_0_0.Op != OpAddr { break } itab := auxToSym(v_0_0_0_0_0.Aux) v_0_0_0_0_0_0 := v_0_0_0_0_0.Args[0] if v_0_0_0_0_0_0.Op != OpSB { break } mem := v_1 if !(devirt(v, itab, off) != nil) { break } v.reset(OpStaticCall) v.AuxInt = int32ToAuxInt(int32(argsize)) v.Aux = symToAux(devirt(v, itab, off)) v.AddArg(mem) return true } return false } func rewriteValuegeneric_OpIsInBounds(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (IsInBounds (ZeroExt8to32 _) (Const32 [c])) // cond: (1 << 8) <= c // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt8to32 || v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !((1 << 8) <= c) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt8to64 _) (Const64 [c])) // cond: (1 << 8) <= c // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt8to64 || v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !((1 << 8) <= c) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt16to32 _) (Const32 [c])) // cond: (1 << 16) <= c // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt16to32 || v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !((1 << 16) <= c) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt16to64 _) (Const64 [c])) // cond: (1 << 16) <= c // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt16to64 || v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !((1 << 16) <= c) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds x x) // result: (ConstBool [false]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } // match: (IsInBounds (And8 (Const8 [c]) _) (Const8 [d])) // cond: 0 <= c && c < d // result: (ConstBool [true]) for { if v_0.Op != OpAnd8 { break } v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1.AuxInt) if !(0 <= c && c < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (ZeroExt8to16 (And8 (Const8 [c]) _)) (Const16 [d])) // cond: 0 <= c && int16(c) < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt8to16 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpAnd8 { break } v_0_0_0 := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { if v_0_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) if !(0 <= c && int16(c) < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (ZeroExt8to32 (And8 (Const8 [c]) _)) (Const32 [d])) // cond: 0 <= c && int32(c) < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt8to32 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpAnd8 { break } v_0_0_0 := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { if v_0_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) if !(0 <= c && int32(c) < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (ZeroExt8to64 (And8 (Const8 [c]) _)) (Const64 [d])) // cond: 0 <= c && int64(c) < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt8to64 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpAnd8 { break } v_0_0_0 := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { if v_0_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) if !(0 <= c && int64(c) < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (And16 (Const16 [c]) _) (Const16 [d])) // cond: 0 <= c && c < d // result: (ConstBool [true]) for { if v_0.Op != OpAnd16 { break } v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) if !(0 <= c && c < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (ZeroExt16to32 (And16 (Const16 [c]) _)) (Const32 [d])) // cond: 0 <= c && int32(c) < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt16to32 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpAnd16 { break } v_0_0_0 := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { if v_0_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) if !(0 <= c && int32(c) < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (ZeroExt16to64 (And16 (Const16 [c]) _)) (Const64 [d])) // cond: 0 <= c && int64(c) < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt16to64 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpAnd16 { break } v_0_0_0 := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { if v_0_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) if !(0 <= c && int64(c) < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (And32 (Const32 [c]) _) (Const32 [d])) // cond: 0 <= c && c < d // result: (ConstBool [true]) for { if v_0.Op != OpAnd32 { break } v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) if !(0 <= c && c < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (ZeroExt32to64 (And32 (Const32 [c]) _)) (Const64 [d])) // cond: 0 <= c && int64(c) < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt32to64 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpAnd32 { break } v_0_0_0 := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0_0, v_0_0_1 = _i0+1, v_0_0_1, v_0_0_0 { if v_0_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) if !(0 <= c && int64(c) < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (And64 (Const64 [c]) _) (Const64 [d])) // cond: 0 <= c && c < d // result: (ConstBool [true]) for { if v_0.Op != OpAnd64 { break } v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) if !(0 <= c && c < d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsInBounds (Const32 [c]) (Const32 [d])) // result: (ConstBool [0 <= c && c < d]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(0 <= c && c < d) return true } // match: (IsInBounds (Const64 [c]) (Const64 [d])) // result: (ConstBool [0 <= c && c < d]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(0 <= c && c < d) return true } // match: (IsInBounds (Mod32u _ y) y) // result: (ConstBool [true]) for { if v_0.Op != OpMod32u { break } y := v_0.Args[1] if y != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (Mod64u _ y) y) // result: (ConstBool [true]) for { if v_0.Op != OpMod64u { break } y := v_0.Args[1] if y != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt8to64 (Rsh8Ux64 _ (Const64 [c]))) (Const64 [d])) // cond: 0 < c && c < 8 && 1<<uint( 8-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt8to64 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh8Ux64 { break } _ = v_0_0.Args[1] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(0 < c && c < 8 && 1<<uint(8-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt8to32 (Rsh8Ux64 _ (Const64 [c]))) (Const32 [d])) // cond: 0 < c && c < 8 && 1<<uint( 8-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt8to32 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh8Ux64 { break } _ = v_0_0.Args[1] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_0_1.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) if !(0 < c && c < 8 && 1<<uint(8-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt8to16 (Rsh8Ux64 _ (Const64 [c]))) (Const16 [d])) // cond: 0 < c && c < 8 && 1<<uint( 8-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt8to16 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh8Ux64 { break } _ = v_0_0.Args[1] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_0_1.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) if !(0 < c && c < 8 && 1<<uint(8-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (Rsh8Ux64 _ (Const64 [c])) (Const64 [d])) // cond: 0 < c && c < 8 && 1<<uint( 8-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpRsh8Ux64 { break } _ = v_0.Args[1] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(0 < c && c < 8 && 1<<uint(8-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt16to64 (Rsh16Ux64 _ (Const64 [c]))) (Const64 [d])) // cond: 0 < c && c < 16 && 1<<uint(16-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt16to64 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh16Ux64 { break } _ = v_0_0.Args[1] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(0 < c && c < 16 && 1<<uint(16-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt16to32 (Rsh16Ux64 _ (Const64 [c]))) (Const64 [d])) // cond: 0 < c && c < 16 && 1<<uint(16-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt16to32 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh16Ux64 { break } _ = v_0_0.Args[1] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(0 < c && c < 16 && 1<<uint(16-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (Rsh16Ux64 _ (Const64 [c])) (Const64 [d])) // cond: 0 < c && c < 16 && 1<<uint(16-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpRsh16Ux64 { break } _ = v_0.Args[1] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(0 < c && c < 16 && 1<<uint(16-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (ZeroExt32to64 (Rsh32Ux64 _ (Const64 [c]))) (Const64 [d])) // cond: 0 < c && c < 32 && 1<<uint(32-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpZeroExt32to64 { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh32Ux64 { break } _ = v_0_0.Args[1] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(0 < c && c < 32 && 1<<uint(32-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (Rsh32Ux64 _ (Const64 [c])) (Const64 [d])) // cond: 0 < c && c < 32 && 1<<uint(32-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpRsh32Ux64 { break } _ = v_0.Args[1] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(0 < c && c < 32 && 1<<uint(32-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsInBounds (Rsh64Ux64 _ (Const64 [c])) (Const64 [d])) // cond: 0 < c && c < 64 && 1<<uint(64-c)-1 < d // result: (ConstBool [true]) for { if v_0.Op != OpRsh64Ux64 { break } _ = v_0.Args[1] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(0 < c && c < 64 && 1<<uint(64-c)-1 < d) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } return false } func rewriteValuegeneric_OpIsNonNil(v *Value) bool { v_0 := v.Args[0] // match: (IsNonNil (ConstNil)) // result: (ConstBool [false]) for { if v_0.Op != OpConstNil { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } // match: (IsNonNil (Const32 [c])) // result: (ConstBool [c != 0]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != 0) return true } // match: (IsNonNil (Const64 [c])) // result: (ConstBool [c != 0]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != 0) return true } // match: (IsNonNil (Addr _)) // result: (ConstBool [true]) for { if v_0.Op != OpAddr { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsNonNil (LocalAddr _ _)) // result: (ConstBool [true]) for { if v_0.Op != OpLocalAddr { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } return false } func rewriteValuegeneric_OpIsSliceInBounds(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (IsSliceInBounds x x) // result: (ConstBool [true]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsSliceInBounds (And32 (Const32 [c]) _) (Const32 [d])) // cond: 0 <= c && c <= d // result: (ConstBool [true]) for { if v_0.Op != OpAnd32 { break } v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) if !(0 <= c && c <= d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsSliceInBounds (And64 (Const64 [c]) _) (Const64 [d])) // cond: 0 <= c && c <= d // result: (ConstBool [true]) for { if v_0.Op != OpAnd64 { break } v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) if !(0 <= c && c <= d) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (IsSliceInBounds (Const32 [0]) _) // result: (ConstBool [true]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsSliceInBounds (Const64 [0]) _) // result: (ConstBool [true]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } // match: (IsSliceInBounds (Const32 [c]) (Const32 [d])) // result: (ConstBool [0 <= c && c <= d]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(0 <= c && c <= d) return true } // match: (IsSliceInBounds (Const64 [c]) (Const64 [d])) // result: (ConstBool [0 <= c && c <= d]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(0 <= c && c <= d) return true } // match: (IsSliceInBounds (SliceLen x) (SliceCap x)) // result: (ConstBool [true]) for { if v_0.Op != OpSliceLen { break } x := v_0.Args[0] if v_1.Op != OpSliceCap || x != v_1.Args[0] { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } return false } func rewriteValuegeneric_OpLeq16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq16 (Const16 [c]) (Const16 [d])) // result: (ConstBool [c <= d]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c <= d) return true } // match: (Leq16 (Const16 [0]) (And16 _ (Const16 [c]))) // cond: c >= 0 // result: (ConstBool [true]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 || v_1.Op != OpAnd16 { break } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { if v_1_1.Op != OpConst16 { continue } c := auxIntToInt16(v_1_1.AuxInt) if !(c >= 0) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (Leq16 (Const16 [0]) (Rsh16Ux64 _ (Const64 [c]))) // cond: c > 0 // result: (ConstBool [true]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 || v_1.Op != OpRsh16Ux64 { break } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { break } c := auxIntToInt64(v_1_1.AuxInt) if !(c > 0) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } return false } func rewriteValuegeneric_OpLeq16U(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq16U (Const16 [c]) (Const16 [d])) // result: (ConstBool [uint16(c) <= uint16(d)]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(uint16(c) <= uint16(d)) return true } return false } func rewriteValuegeneric_OpLeq32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq32 (Const32 [c]) (Const32 [d])) // result: (ConstBool [c <= d]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c <= d) return true } // match: (Leq32 (Const32 [0]) (And32 _ (Const32 [c]))) // cond: c >= 0 // result: (ConstBool [true]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 || v_1.Op != OpAnd32 { break } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { if v_1_1.Op != OpConst32 { continue } c := auxIntToInt32(v_1_1.AuxInt) if !(c >= 0) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (Leq32 (Const32 [0]) (Rsh32Ux64 _ (Const64 [c]))) // cond: c > 0 // result: (ConstBool [true]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 || v_1.Op != OpRsh32Ux64 { break } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { break } c := auxIntToInt64(v_1_1.AuxInt) if !(c > 0) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } return false } func rewriteValuegeneric_OpLeq32F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq32F (Const32F [c]) (Const32F [d])) // result: (ConstBool [c <= d]) for { if v_0.Op != OpConst32F { break } c := auxIntToFloat32(v_0.AuxInt) if v_1.Op != OpConst32F { break } d := auxIntToFloat32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c <= d) return true } return false } func rewriteValuegeneric_OpLeq32U(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq32U (Const32 [c]) (Const32 [d])) // result: (ConstBool [uint32(c) <= uint32(d)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(uint32(c) <= uint32(d)) return true } return false } func rewriteValuegeneric_OpLeq64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq64 (Const64 [c]) (Const64 [d])) // result: (ConstBool [c <= d]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c <= d) return true } // match: (Leq64 (Const64 [0]) (And64 _ (Const64 [c]))) // cond: c >= 0 // result: (ConstBool [true]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 || v_1.Op != OpAnd64 { break } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { if v_1_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1_1.AuxInt) if !(c >= 0) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (Leq64 (Const64 [0]) (Rsh64Ux64 _ (Const64 [c]))) // cond: c > 0 // result: (ConstBool [true]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 || v_1.Op != OpRsh64Ux64 { break } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { break } c := auxIntToInt64(v_1_1.AuxInt) if !(c > 0) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } return false } func rewriteValuegeneric_OpLeq64F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq64F (Const64F [c]) (Const64F [d])) // result: (ConstBool [c <= d]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) if v_1.Op != OpConst64F { break } d := auxIntToFloat64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c <= d) return true } return false } func rewriteValuegeneric_OpLeq64U(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq64U (Const64 [c]) (Const64 [d])) // result: (ConstBool [uint64(c) <= uint64(d)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(uint64(c) <= uint64(d)) return true } return false } func rewriteValuegeneric_OpLeq8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq8 (Const8 [c]) (Const8 [d])) // result: (ConstBool [c <= d]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c <= d) return true } // match: (Leq8 (Const8 [0]) (And8 _ (Const8 [c]))) // cond: c >= 0 // result: (ConstBool [true]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 || v_1.Op != OpAnd8 { break } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_1_0, v_1_1 = _i0+1, v_1_1, v_1_0 { if v_1_1.Op != OpConst8 { continue } c := auxIntToInt8(v_1_1.AuxInt) if !(c >= 0) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (Leq8 (Const8 [0]) (Rsh8Ux64 _ (Const64 [c]))) // cond: c > 0 // result: (ConstBool [true]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 || v_1.Op != OpRsh8Ux64 { break } _ = v_1.Args[1] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { break } c := auxIntToInt64(v_1_1.AuxInt) if !(c > 0) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } return false } func rewriteValuegeneric_OpLeq8U(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Leq8U (Const8 [c]) (Const8 [d])) // result: (ConstBool [ uint8(c) <= uint8(d)]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(uint8(c) <= uint8(d)) return true } return false } func rewriteValuegeneric_OpLess16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less16 (Const16 [c]) (Const16 [d])) // result: (ConstBool [c < d]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c < d) return true } return false } func rewriteValuegeneric_OpLess16U(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less16U (Const16 [c]) (Const16 [d])) // result: (ConstBool [uint16(c) < uint16(d)]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(uint16(c) < uint16(d)) return true } return false } func rewriteValuegeneric_OpLess32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less32 (Const32 [c]) (Const32 [d])) // result: (ConstBool [c < d]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c < d) return true } return false } func rewriteValuegeneric_OpLess32F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less32F (Const32F [c]) (Const32F [d])) // result: (ConstBool [c < d]) for { if v_0.Op != OpConst32F { break } c := auxIntToFloat32(v_0.AuxInt) if v_1.Op != OpConst32F { break } d := auxIntToFloat32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c < d) return true } return false } func rewriteValuegeneric_OpLess32U(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less32U (Const32 [c]) (Const32 [d])) // result: (ConstBool [uint32(c) < uint32(d)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(uint32(c) < uint32(d)) return true } return false } func rewriteValuegeneric_OpLess64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less64 (Const64 [c]) (Const64 [d])) // result: (ConstBool [c < d]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c < d) return true } return false } func rewriteValuegeneric_OpLess64F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less64F (Const64F [c]) (Const64F [d])) // result: (ConstBool [c < d]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) if v_1.Op != OpConst64F { break } d := auxIntToFloat64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c < d) return true } return false } func rewriteValuegeneric_OpLess64U(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less64U (Const64 [c]) (Const64 [d])) // result: (ConstBool [uint64(c) < uint64(d)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(uint64(c) < uint64(d)) return true } return false } func rewriteValuegeneric_OpLess8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less8 (Const8 [c]) (Const8 [d])) // result: (ConstBool [c < d]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c < d) return true } return false } func rewriteValuegeneric_OpLess8U(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Less8U (Const8 [c]) (Const8 [d])) // result: (ConstBool [ uint8(c) < uint8(d)]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(uint8(c) < uint8(d)) return true } return false } func rewriteValuegeneric_OpLoad(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block fe := b.Func.fe // match: (Load <t1> p1 (Store {t2} p2 x _)) // cond: isSamePtr(p1, p2) && t1.Compare(x.Type) == types.CMPeq && t1.Size() == t2.Size() // result: x for { t1 := v.Type p1 := v_0 if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) x := v_1.Args[1] p2 := v_1.Args[0] if !(isSamePtr(p1, p2) && t1.Compare(x.Type) == types.CMPeq && t1.Size() == t2.Size()) { break } v.copyOf(x) return true } // match: (Load <t1> p1 (Store {t2} p2 _ (Store {t3} p3 x _))) // cond: isSamePtr(p1, p3) && t1.Compare(x.Type) == types.CMPeq && t1.Size() == t2.Size() && disjoint(p3, t3.Size(), p2, t2.Size()) // result: x for { t1 := v.Type p1 := v_0 if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[2] p2 := v_1.Args[0] v_1_2 := v_1.Args[2] if v_1_2.Op != OpStore { break } t3 := auxToType(v_1_2.Aux) x := v_1_2.Args[1] p3 := v_1_2.Args[0] if !(isSamePtr(p1, p3) && t1.Compare(x.Type) == types.CMPeq && t1.Size() == t2.Size() && disjoint(p3, t3.Size(), p2, t2.Size())) { break } v.copyOf(x) return true } // match: (Load <t1> p1 (Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 x _)))) // cond: isSamePtr(p1, p4) && t1.Compare(x.Type) == types.CMPeq && t1.Size() == t2.Size() && disjoint(p4, t4.Size(), p2, t2.Size()) && disjoint(p4, t4.Size(), p3, t3.Size()) // result: x for { t1 := v.Type p1 := v_0 if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[2] p2 := v_1.Args[0] v_1_2 := v_1.Args[2] if v_1_2.Op != OpStore { break } t3 := auxToType(v_1_2.Aux) _ = v_1_2.Args[2] p3 := v_1_2.Args[0] v_1_2_2 := v_1_2.Args[2] if v_1_2_2.Op != OpStore { break } t4 := auxToType(v_1_2_2.Aux) x := v_1_2_2.Args[1] p4 := v_1_2_2.Args[0] if !(isSamePtr(p1, p4) && t1.Compare(x.Type) == types.CMPeq && t1.Size() == t2.Size() && disjoint(p4, t4.Size(), p2, t2.Size()) && disjoint(p4, t4.Size(), p3, t3.Size())) { break } v.copyOf(x) return true } // match: (Load <t1> p1 (Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Store {t5} p5 x _))))) // cond: isSamePtr(p1, p5) && t1.Compare(x.Type) == types.CMPeq && t1.Size() == t2.Size() && disjoint(p5, t5.Size(), p2, t2.Size()) && disjoint(p5, t5.Size(), p3, t3.Size()) && disjoint(p5, t5.Size(), p4, t4.Size()) // result: x for { t1 := v.Type p1 := v_0 if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[2] p2 := v_1.Args[0] v_1_2 := v_1.Args[2] if v_1_2.Op != OpStore { break } t3 := auxToType(v_1_2.Aux) _ = v_1_2.Args[2] p3 := v_1_2.Args[0] v_1_2_2 := v_1_2.Args[2] if v_1_2_2.Op != OpStore { break } t4 := auxToType(v_1_2_2.Aux) _ = v_1_2_2.Args[2] p4 := v_1_2_2.Args[0] v_1_2_2_2 := v_1_2_2.Args[2] if v_1_2_2_2.Op != OpStore { break } t5 := auxToType(v_1_2_2_2.Aux) x := v_1_2_2_2.Args[1] p5 := v_1_2_2_2.Args[0] if !(isSamePtr(p1, p5) && t1.Compare(x.Type) == types.CMPeq && t1.Size() == t2.Size() && disjoint(p5, t5.Size(), p2, t2.Size()) && disjoint(p5, t5.Size(), p3, t3.Size()) && disjoint(p5, t5.Size(), p4, t4.Size())) { break } v.copyOf(x) return true } // match: (Load <t1> p1 (Store {t2} p2 (Const64 [x]) _)) // cond: isSamePtr(p1,p2) && sizeof(t2) == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x))) // result: (Const64F [math.Float64frombits(uint64(x))]) for { t1 := v.Type p1 := v_0 if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[1] p2 := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { break } x := auxIntToInt64(v_1_1.AuxInt) if !(isSamePtr(p1, p2) && sizeof(t2) == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x)))) { break } v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(math.Float64frombits(uint64(x))) return true } // match: (Load <t1> p1 (Store {t2} p2 (Const32 [x]) _)) // cond: isSamePtr(p1,p2) && sizeof(t2) == 4 && is32BitFloat(t1) && !math.IsNaN(float64(math.Float32frombits(uint32(x)))) // result: (Const32F [math.Float32frombits(uint32(x))]) for { t1 := v.Type p1 := v_0 if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[1] p2 := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { break } x := auxIntToInt32(v_1_1.AuxInt) if !(isSamePtr(p1, p2) && sizeof(t2) == 4 && is32BitFloat(t1) && !math.IsNaN(float64(math.Float32frombits(uint32(x))))) { break } v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(math.Float32frombits(uint32(x))) return true } // match: (Load <t1> p1 (Store {t2} p2 (Const64F [x]) _)) // cond: isSamePtr(p1,p2) && sizeof(t2) == 8 && is64BitInt(t1) // result: (Const64 [int64(math.Float64bits(x))]) for { t1 := v.Type p1 := v_0 if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[1] p2 := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64F { break } x := auxIntToFloat64(v_1_1.AuxInt) if !(isSamePtr(p1, p2) && sizeof(t2) == 8 && is64BitInt(t1)) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(math.Float64bits(x))) return true } // match: (Load <t1> p1 (Store {t2} p2 (Const32F [x]) _)) // cond: isSamePtr(p1,p2) && sizeof(t2) == 4 && is32BitInt(t1) // result: (Const32 [int32(math.Float32bits(x))]) for { t1 := v.Type p1 := v_0 if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[1] p2 := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32F { break } x := auxIntToFloat32(v_1_1.AuxInt) if !(isSamePtr(p1, p2) && sizeof(t2) == 4 && is32BitInt(t1)) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(math.Float32bits(x))) return true } // match: (Load <t1> op:(OffPtr [o1] p1) (Store {t2} p2 _ mem:(Zero [n] p3 _))) // cond: o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p3) && fe.CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) // result: @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p3) mem) for { t1 := v.Type op := v_0 if op.Op != OpOffPtr { break } o1 := auxIntToInt64(op.AuxInt) p1 := op.Args[0] if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[2] p2 := v_1.Args[0] mem := v_1.Args[2] if mem.Op != OpZero { break } n := auxIntToInt64(mem.AuxInt) p3 := mem.Args[0] if !(o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p3) && fe.CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size())) { break } b = mem.Block v0 := b.NewValue0(v.Pos, OpLoad, t1) v.copyOf(v0) v1 := b.NewValue0(v.Pos, OpOffPtr, op.Type) v1.AuxInt = int64ToAuxInt(o1) v1.AddArg(p3) v0.AddArg2(v1, mem) return true } // match: (Load <t1> op:(OffPtr [o1] p1) (Store {t2} p2 _ (Store {t3} p3 _ mem:(Zero [n] p4 _)))) // cond: o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p4) && fe.CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) // result: @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p4) mem) for { t1 := v.Type op := v_0 if op.Op != OpOffPtr { break } o1 := auxIntToInt64(op.AuxInt) p1 := op.Args[0] if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[2] p2 := v_1.Args[0] v_1_2 := v_1.Args[2] if v_1_2.Op != OpStore { break } t3 := auxToType(v_1_2.Aux) _ = v_1_2.Args[2] p3 := v_1_2.Args[0] mem := v_1_2.Args[2] if mem.Op != OpZero { break } n := auxIntToInt64(mem.AuxInt) p4 := mem.Args[0] if !(o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p4) && fe.CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size())) { break } b = mem.Block v0 := b.NewValue0(v.Pos, OpLoad, t1) v.copyOf(v0) v1 := b.NewValue0(v.Pos, OpOffPtr, op.Type) v1.AuxInt = int64ToAuxInt(o1) v1.AddArg(p4) v0.AddArg2(v1, mem) return true } // match: (Load <t1> op:(OffPtr [o1] p1) (Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ mem:(Zero [n] p5 _))))) // cond: o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p5) && fe.CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size()) // result: @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p5) mem) for { t1 := v.Type op := v_0 if op.Op != OpOffPtr { break } o1 := auxIntToInt64(op.AuxInt) p1 := op.Args[0] if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[2] p2 := v_1.Args[0] v_1_2 := v_1.Args[2] if v_1_2.Op != OpStore { break } t3 := auxToType(v_1_2.Aux) _ = v_1_2.Args[2] p3 := v_1_2.Args[0] v_1_2_2 := v_1_2.Args[2] if v_1_2_2.Op != OpStore { break } t4 := auxToType(v_1_2_2.Aux) _ = v_1_2_2.Args[2] p4 := v_1_2_2.Args[0] mem := v_1_2_2.Args[2] if mem.Op != OpZero { break } n := auxIntToInt64(mem.AuxInt) p5 := mem.Args[0] if !(o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p5) && fe.CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size())) { break } b = mem.Block v0 := b.NewValue0(v.Pos, OpLoad, t1) v.copyOf(v0) v1 := b.NewValue0(v.Pos, OpOffPtr, op.Type) v1.AuxInt = int64ToAuxInt(o1) v1.AddArg(p5) v0.AddArg2(v1, mem) return true } // match: (Load <t1> op:(OffPtr [o1] p1) (Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Store {t5} p5 _ mem:(Zero [n] p6 _)))))) // cond: o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p6) && fe.CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size()) && disjoint(op, t1.Size(), p5, t5.Size()) // result: @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p6) mem) for { t1 := v.Type op := v_0 if op.Op != OpOffPtr { break } o1 := auxIntToInt64(op.AuxInt) p1 := op.Args[0] if v_1.Op != OpStore { break } t2 := auxToType(v_1.Aux) _ = v_1.Args[2] p2 := v_1.Args[0] v_1_2 := v_1.Args[2] if v_1_2.Op != OpStore { break } t3 := auxToType(v_1_2.Aux) _ = v_1_2.Args[2] p3 := v_1_2.Args[0] v_1_2_2 := v_1_2.Args[2] if v_1_2_2.Op != OpStore { break } t4 := auxToType(v_1_2_2.Aux) _ = v_1_2_2.Args[2] p4 := v_1_2_2.Args[0] v_1_2_2_2 := v_1_2_2.Args[2] if v_1_2_2_2.Op != OpStore { break } t5 := auxToType(v_1_2_2_2.Aux) _ = v_1_2_2_2.Args[2] p5 := v_1_2_2_2.Args[0] mem := v_1_2_2_2.Args[2] if mem.Op != OpZero { break } n := auxIntToInt64(mem.AuxInt) p6 := mem.Args[0] if !(o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p6) && fe.CanSSA(t1) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size()) && disjoint(op, t1.Size(), p5, t5.Size())) { break } b = mem.Block v0 := b.NewValue0(v.Pos, OpLoad, t1) v.copyOf(v0) v1 := b.NewValue0(v.Pos, OpOffPtr, op.Type) v1.AuxInt = int64ToAuxInt(o1) v1.AddArg(p6) v0.AddArg2(v1, mem) return true } // match: (Load <t1> (OffPtr [o] p1) (Zero [n] p2 _)) // cond: t1.IsBoolean() && isSamePtr(p1, p2) && n >= o + 1 // result: (ConstBool [false]) for { t1 := v.Type if v_0.Op != OpOffPtr { break } o := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpZero { break } n := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(t1.IsBoolean() && isSamePtr(p1, p2) && n >= o+1) { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } // match: (Load <t1> (OffPtr [o] p1) (Zero [n] p2 _)) // cond: is8BitInt(t1) && isSamePtr(p1, p2) && n >= o + 1 // result: (Const8 [0]) for { t1 := v.Type if v_0.Op != OpOffPtr { break } o := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpZero { break } n := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(is8BitInt(t1) && isSamePtr(p1, p2) && n >= o+1) { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (Load <t1> (OffPtr [o] p1) (Zero [n] p2 _)) // cond: is16BitInt(t1) && isSamePtr(p1, p2) && n >= o + 2 // result: (Const16 [0]) for { t1 := v.Type if v_0.Op != OpOffPtr { break } o := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpZero { break } n := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(is16BitInt(t1) && isSamePtr(p1, p2) && n >= o+2) { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } // match: (Load <t1> (OffPtr [o] p1) (Zero [n] p2 _)) // cond: is32BitInt(t1) && isSamePtr(p1, p2) && n >= o + 4 // result: (Const32 [0]) for { t1 := v.Type if v_0.Op != OpOffPtr { break } o := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpZero { break } n := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(is32BitInt(t1) && isSamePtr(p1, p2) && n >= o+4) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Load <t1> (OffPtr [o] p1) (Zero [n] p2 _)) // cond: is64BitInt(t1) && isSamePtr(p1, p2) && n >= o + 8 // result: (Const64 [0]) for { t1 := v.Type if v_0.Op != OpOffPtr { break } o := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpZero { break } n := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(is64BitInt(t1) && isSamePtr(p1, p2) && n >= o+8) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Load <t1> (OffPtr [o] p1) (Zero [n] p2 _)) // cond: is32BitFloat(t1) && isSamePtr(p1, p2) && n >= o + 4 // result: (Const32F [0]) for { t1 := v.Type if v_0.Op != OpOffPtr { break } o := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpZero { break } n := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(is32BitFloat(t1) && isSamePtr(p1, p2) && n >= o+4) { break } v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(0) return true } // match: (Load <t1> (OffPtr [o] p1) (Zero [n] p2 _)) // cond: is64BitFloat(t1) && isSamePtr(p1, p2) && n >= o + 8 // result: (Const64F [0]) for { t1 := v.Type if v_0.Op != OpOffPtr { break } o := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpZero { break } n := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(is64BitFloat(t1) && isSamePtr(p1, p2) && n >= o+8) { break } v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(0) return true } // match: (Load <t> _ _) // cond: t.IsStruct() && t.NumFields() == 0 && fe.CanSSA(t) // result: (StructMake0) for { t := v.Type if !(t.IsStruct() && t.NumFields() == 0 && fe.CanSSA(t)) { break } v.reset(OpStructMake0) return true } // match: (Load <t> ptr mem) // cond: t.IsStruct() && t.NumFields() == 1 && fe.CanSSA(t) // result: (StructMake1 (Load <t.FieldType(0)> (OffPtr <t.FieldType(0).PtrTo()> [0] ptr) mem)) for { t := v.Type ptr := v_0 mem := v_1 if !(t.IsStruct() && t.NumFields() == 1 && fe.CanSSA(t)) { break } v.reset(OpStructMake1) v0 := b.NewValue0(v.Pos, OpLoad, t.FieldType(0)) v1 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v1.AuxInt = int64ToAuxInt(0) v1.AddArg(ptr) v0.AddArg2(v1, mem) v.AddArg(v0) return true } // match: (Load <t> ptr mem) // cond: t.IsStruct() && t.NumFields() == 2 && fe.CanSSA(t) // result: (StructMake2 (Load <t.FieldType(0)> (OffPtr <t.FieldType(0).PtrTo()> [0] ptr) mem) (Load <t.FieldType(1)> (OffPtr <t.FieldType(1).PtrTo()> [t.FieldOff(1)] ptr) mem)) for { t := v.Type ptr := v_0 mem := v_1 if !(t.IsStruct() && t.NumFields() == 2 && fe.CanSSA(t)) { break } v.reset(OpStructMake2) v0 := b.NewValue0(v.Pos, OpLoad, t.FieldType(0)) v1 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v1.AuxInt = int64ToAuxInt(0) v1.AddArg(ptr) v0.AddArg2(v1, mem) v2 := b.NewValue0(v.Pos, OpLoad, t.FieldType(1)) v3 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(1).PtrTo()) v3.AuxInt = int64ToAuxInt(t.FieldOff(1)) v3.AddArg(ptr) v2.AddArg2(v3, mem) v.AddArg2(v0, v2) return true } // match: (Load <t> ptr mem) // cond: t.IsStruct() && t.NumFields() == 3 && fe.CanSSA(t) // result: (StructMake3 (Load <t.FieldType(0)> (OffPtr <t.FieldType(0).PtrTo()> [0] ptr) mem) (Load <t.FieldType(1)> (OffPtr <t.FieldType(1).PtrTo()> [t.FieldOff(1)] ptr) mem) (Load <t.FieldType(2)> (OffPtr <t.FieldType(2).PtrTo()> [t.FieldOff(2)] ptr) mem)) for { t := v.Type ptr := v_0 mem := v_1 if !(t.IsStruct() && t.NumFields() == 3 && fe.CanSSA(t)) { break } v.reset(OpStructMake3) v0 := b.NewValue0(v.Pos, OpLoad, t.FieldType(0)) v1 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v1.AuxInt = int64ToAuxInt(0) v1.AddArg(ptr) v0.AddArg2(v1, mem) v2 := b.NewValue0(v.Pos, OpLoad, t.FieldType(1)) v3 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(1).PtrTo()) v3.AuxInt = int64ToAuxInt(t.FieldOff(1)) v3.AddArg(ptr) v2.AddArg2(v3, mem) v4 := b.NewValue0(v.Pos, OpLoad, t.FieldType(2)) v5 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(2).PtrTo()) v5.AuxInt = int64ToAuxInt(t.FieldOff(2)) v5.AddArg(ptr) v4.AddArg2(v5, mem) v.AddArg3(v0, v2, v4) return true } // match: (Load <t> ptr mem) // cond: t.IsStruct() && t.NumFields() == 4 && fe.CanSSA(t) // result: (StructMake4 (Load <t.FieldType(0)> (OffPtr <t.FieldType(0).PtrTo()> [0] ptr) mem) (Load <t.FieldType(1)> (OffPtr <t.FieldType(1).PtrTo()> [t.FieldOff(1)] ptr) mem) (Load <t.FieldType(2)> (OffPtr <t.FieldType(2).PtrTo()> [t.FieldOff(2)] ptr) mem) (Load <t.FieldType(3)> (OffPtr <t.FieldType(3).PtrTo()> [t.FieldOff(3)] ptr) mem)) for { t := v.Type ptr := v_0 mem := v_1 if !(t.IsStruct() && t.NumFields() == 4 && fe.CanSSA(t)) { break } v.reset(OpStructMake4) v0 := b.NewValue0(v.Pos, OpLoad, t.FieldType(0)) v1 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v1.AuxInt = int64ToAuxInt(0) v1.AddArg(ptr) v0.AddArg2(v1, mem) v2 := b.NewValue0(v.Pos, OpLoad, t.FieldType(1)) v3 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(1).PtrTo()) v3.AuxInt = int64ToAuxInt(t.FieldOff(1)) v3.AddArg(ptr) v2.AddArg2(v3, mem) v4 := b.NewValue0(v.Pos, OpLoad, t.FieldType(2)) v5 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(2).PtrTo()) v5.AuxInt = int64ToAuxInt(t.FieldOff(2)) v5.AddArg(ptr) v4.AddArg2(v5, mem) v6 := b.NewValue0(v.Pos, OpLoad, t.FieldType(3)) v7 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(3).PtrTo()) v7.AuxInt = int64ToAuxInt(t.FieldOff(3)) v7.AddArg(ptr) v6.AddArg2(v7, mem) v.AddArg4(v0, v2, v4, v6) return true } // match: (Load <t> _ _) // cond: t.IsArray() && t.NumElem() == 0 // result: (ArrayMake0) for { t := v.Type if !(t.IsArray() && t.NumElem() == 0) { break } v.reset(OpArrayMake0) return true } // match: (Load <t> ptr mem) // cond: t.IsArray() && t.NumElem() == 1 && fe.CanSSA(t) // result: (ArrayMake1 (Load <t.Elem()> ptr mem)) for { t := v.Type ptr := v_0 mem := v_1 if !(t.IsArray() && t.NumElem() == 1 && fe.CanSSA(t)) { break } v.reset(OpArrayMake1) v0 := b.NewValue0(v.Pos, OpLoad, t.Elem()) v0.AddArg2(ptr, mem) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpLsh16x16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh16x16 <t> x (Const16 [c])) // result: (Lsh16x64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpLsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Lsh16x16 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh16x32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh16x32 <t> x (Const32 [c])) // result: (Lsh16x64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpLsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Lsh16x32 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh16x64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Lsh16x64 (Const16 [c]) (Const64 [d])) // result: (Const16 [c << uint64(d)]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c << uint64(d)) return true } // match: (Lsh16x64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Lsh16x64 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } // match: (Lsh16x64 _ (Const64 [c])) // cond: uint64(c) >= 16 // result: (Const16 [0]) for { if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(uint64(c) >= 16) { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } // match: (Lsh16x64 <t> (Lsh16x64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Lsh16x64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpLsh16x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpLsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Lsh16x64 (Rsh16Ux64 (Lsh16x64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) // result: (Lsh16x64 x (Const64 <typ.UInt64> [c1-c2+c3])) for { if v_0.Op != OpRsh16Ux64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpLsh16x64 { break } _ = v_0_0.Args[1] x := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c1 := auxIntToInt64(v_0_0_1.AuxInt) v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } c3 := auxIntToInt64(v_1.AuxInt) if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { break } v.reset(OpLsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpLsh16x8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh16x8 <t> x (Const8 [c])) // result: (Lsh16x64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpLsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Lsh16x8 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh32x16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh32x16 <t> x (Const16 [c])) // result: (Lsh32x64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpLsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Lsh32x16 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh32x32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh32x32 <t> x (Const32 [c])) // result: (Lsh32x64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpLsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Lsh32x32 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh32x64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Lsh32x64 (Const32 [c]) (Const64 [d])) // result: (Const32 [c << uint64(d)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c << uint64(d)) return true } // match: (Lsh32x64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Lsh32x64 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Lsh32x64 _ (Const64 [c])) // cond: uint64(c) >= 32 // result: (Const32 [0]) for { if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(uint64(c) >= 32) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Lsh32x64 <t> (Lsh32x64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Lsh32x64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpLsh32x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpLsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Lsh32x64 (Rsh32Ux64 (Lsh32x64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) // result: (Lsh32x64 x (Const64 <typ.UInt64> [c1-c2+c3])) for { if v_0.Op != OpRsh32Ux64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpLsh32x64 { break } _ = v_0_0.Args[1] x := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c1 := auxIntToInt64(v_0_0_1.AuxInt) v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } c3 := auxIntToInt64(v_1.AuxInt) if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { break } v.reset(OpLsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpLsh32x8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh32x8 <t> x (Const8 [c])) // result: (Lsh32x64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpLsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Lsh32x8 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh64x16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh64x16 <t> x (Const16 [c])) // result: (Lsh64x64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpLsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Lsh64x16 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh64x32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh64x32 <t> x (Const32 [c])) // result: (Lsh64x64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpLsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Lsh64x32 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh64x64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Lsh64x64 (Const64 [c]) (Const64 [d])) // result: (Const64 [c << uint64(d)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c << uint64(d)) return true } // match: (Lsh64x64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Lsh64x64 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Lsh64x64 _ (Const64 [c])) // cond: uint64(c) >= 64 // result: (Const64 [0]) for { if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(uint64(c) >= 64) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Lsh64x64 <t> (Lsh64x64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Lsh64x64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpLsh64x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpLsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Lsh64x64 (Rsh64Ux64 (Lsh64x64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) // result: (Lsh64x64 x (Const64 <typ.UInt64> [c1-c2+c3])) for { if v_0.Op != OpRsh64Ux64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpLsh64x64 { break } _ = v_0_0.Args[1] x := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c1 := auxIntToInt64(v_0_0_1.AuxInt) v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } c3 := auxIntToInt64(v_1.AuxInt) if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { break } v.reset(OpLsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpLsh64x8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh64x8 <t> x (Const8 [c])) // result: (Lsh64x64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpLsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Lsh64x8 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh8x16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh8x16 <t> x (Const16 [c])) // result: (Lsh8x64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpLsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Lsh8x16 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh8x32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh8x32 <t> x (Const32 [c])) // result: (Lsh8x64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpLsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Lsh8x32 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpLsh8x64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Lsh8x64 (Const8 [c]) (Const64 [d])) // result: (Const8 [c << uint64(d)]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c << uint64(d)) return true } // match: (Lsh8x64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Lsh8x64 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (Lsh8x64 _ (Const64 [c])) // cond: uint64(c) >= 8 // result: (Const8 [0]) for { if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(uint64(c) >= 8) { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (Lsh8x64 <t> (Lsh8x64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Lsh8x64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpLsh8x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpLsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Lsh8x64 (Rsh8Ux64 (Lsh8x64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) // result: (Lsh8x64 x (Const64 <typ.UInt64> [c1-c2+c3])) for { if v_0.Op != OpRsh8Ux64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpLsh8x64 { break } _ = v_0_0.Args[1] x := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c1 := auxIntToInt64(v_0_0_1.AuxInt) v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } c3 := auxIntToInt64(v_1.AuxInt) if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { break } v.reset(OpLsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpLsh8x8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Lsh8x8 <t> x (Const8 [c])) // result: (Lsh8x64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpLsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Lsh8x8 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpMod16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Mod16 (Const16 [c]) (Const16 [d])) // cond: d != 0 // result: (Const16 [c % d]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c % d) return true } // match: (Mod16 <t> n (Const16 [c])) // cond: isNonNegative(n) && isPowerOfTwo16(c) // result: (And16 n (Const16 <t> [c-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(isNonNegative(n) && isPowerOfTwo16(c)) { break } v.reset(OpAnd16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c - 1) v.AddArg2(n, v0) return true } // match: (Mod16 <t> n (Const16 [c])) // cond: c < 0 && c != -1<<15 // result: (Mod16 <t> n (Const16 <t> [-c])) for { t := v.Type n := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(c < 0 && c != -1<<15) { break } v.reset(OpMod16) v.Type = t v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(-c) v.AddArg2(n, v0) return true } // match: (Mod16 <t> x (Const16 [c])) // cond: x.Op != OpConst16 && (c > 0 || c == -1<<15) // result: (Sub16 x (Mul16 <t> (Div16 <t> x (Const16 <t> [c])) (Const16 <t> [c]))) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(x.Op != OpConst16 && (c > 0 || c == -1<<15)) { break } v.reset(OpSub16) v0 := b.NewValue0(v.Pos, OpMul16, t) v1 := b.NewValue0(v.Pos, OpDiv16, t) v2 := b.NewValue0(v.Pos, OpConst16, t) v2.AuxInt = int16ToAuxInt(c) v1.AddArg2(x, v2) v0.AddArg2(v1, v2) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpMod16u(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Mod16u (Const16 [c]) (Const16 [d])) // cond: d != 0 // result: (Const16 [int16(uint16(c) % uint16(d))]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(int16(uint16(c) % uint16(d))) return true } // match: (Mod16u <t> n (Const16 [c])) // cond: isPowerOfTwo16(c) // result: (And16 n (Const16 <t> [c-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(isPowerOfTwo16(c)) { break } v.reset(OpAnd16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c - 1) v.AddArg2(n, v0) return true } // match: (Mod16u <t> x (Const16 [c])) // cond: x.Op != OpConst16 && c > 0 && umagicOK16(c) // result: (Sub16 x (Mul16 <t> (Div16u <t> x (Const16 <t> [c])) (Const16 <t> [c]))) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(x.Op != OpConst16 && c > 0 && umagicOK16(c)) { break } v.reset(OpSub16) v0 := b.NewValue0(v.Pos, OpMul16, t) v1 := b.NewValue0(v.Pos, OpDiv16u, t) v2 := b.NewValue0(v.Pos, OpConst16, t) v2.AuxInt = int16ToAuxInt(c) v1.AddArg2(x, v2) v0.AddArg2(v1, v2) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpMod32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Mod32 (Const32 [c]) (Const32 [d])) // cond: d != 0 // result: (Const32 [c % d]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c % d) return true } // match: (Mod32 <t> n (Const32 [c])) // cond: isNonNegative(n) && isPowerOfTwo32(c) // result: (And32 n (Const32 <t> [c-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(isNonNegative(n) && isPowerOfTwo32(c)) { break } v.reset(OpAnd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c - 1) v.AddArg2(n, v0) return true } // match: (Mod32 <t> n (Const32 [c])) // cond: c < 0 && c != -1<<31 // result: (Mod32 <t> n (Const32 <t> [-c])) for { t := v.Type n := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(c < 0 && c != -1<<31) { break } v.reset(OpMod32) v.Type = t v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(-c) v.AddArg2(n, v0) return true } // match: (Mod32 <t> x (Const32 [c])) // cond: x.Op != OpConst32 && (c > 0 || c == -1<<31) // result: (Sub32 x (Mul32 <t> (Div32 <t> x (Const32 <t> [c])) (Const32 <t> [c]))) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(x.Op != OpConst32 && (c > 0 || c == -1<<31)) { break } v.reset(OpSub32) v0 := b.NewValue0(v.Pos, OpMul32, t) v1 := b.NewValue0(v.Pos, OpDiv32, t) v2 := b.NewValue0(v.Pos, OpConst32, t) v2.AuxInt = int32ToAuxInt(c) v1.AddArg2(x, v2) v0.AddArg2(v1, v2) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpMod32u(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Mod32u (Const32 [c]) (Const32 [d])) // cond: d != 0 // result: (Const32 [int32(uint32(c) % uint32(d))]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(uint32(c) % uint32(d))) return true } // match: (Mod32u <t> n (Const32 [c])) // cond: isPowerOfTwo32(c) // result: (And32 n (Const32 <t> [c-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(isPowerOfTwo32(c)) { break } v.reset(OpAnd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c - 1) v.AddArg2(n, v0) return true } // match: (Mod32u <t> x (Const32 [c])) // cond: x.Op != OpConst32 && c > 0 && umagicOK32(c) // result: (Sub32 x (Mul32 <t> (Div32u <t> x (Const32 <t> [c])) (Const32 <t> [c]))) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(x.Op != OpConst32 && c > 0 && umagicOK32(c)) { break } v.reset(OpSub32) v0 := b.NewValue0(v.Pos, OpMul32, t) v1 := b.NewValue0(v.Pos, OpDiv32u, t) v2 := b.NewValue0(v.Pos, OpConst32, t) v2.AuxInt = int32ToAuxInt(c) v1.AddArg2(x, v2) v0.AddArg2(v1, v2) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpMod64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Mod64 (Const64 [c]) (Const64 [d])) // cond: d != 0 // result: (Const64 [c % d]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c % d) return true } // match: (Mod64 <t> n (Const64 [c])) // cond: isNonNegative(n) && isPowerOfTwo64(c) // result: (And64 n (Const64 <t> [c-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(isNonNegative(n) && isPowerOfTwo64(c)) { break } v.reset(OpAnd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c - 1) v.AddArg2(n, v0) return true } // match: (Mod64 n (Const64 [-1<<63])) // cond: isNonNegative(n) // result: n for { n := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1<<63 || !(isNonNegative(n)) { break } v.copyOf(n) return true } // match: (Mod64 <t> n (Const64 [c])) // cond: c < 0 && c != -1<<63 // result: (Mod64 <t> n (Const64 <t> [-c])) for { t := v.Type n := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(c < 0 && c != -1<<63) { break } v.reset(OpMod64) v.Type = t v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(-c) v.AddArg2(n, v0) return true } // match: (Mod64 <t> x (Const64 [c])) // cond: x.Op != OpConst64 && (c > 0 || c == -1<<63) // result: (Sub64 x (Mul64 <t> (Div64 <t> x (Const64 <t> [c])) (Const64 <t> [c]))) for { t := v.Type x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(x.Op != OpConst64 && (c > 0 || c == -1<<63)) { break } v.reset(OpSub64) v0 := b.NewValue0(v.Pos, OpMul64, t) v1 := b.NewValue0(v.Pos, OpDiv64, t) v2 := b.NewValue0(v.Pos, OpConst64, t) v2.AuxInt = int64ToAuxInt(c) v1.AddArg2(x, v2) v0.AddArg2(v1, v2) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpMod64u(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Mod64u (Const64 [c]) (Const64 [d])) // cond: d != 0 // result: (Const64 [int64(uint64(c) % uint64(d))]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(uint64(c) % uint64(d))) return true } // match: (Mod64u <t> n (Const64 [c])) // cond: isPowerOfTwo64(c) // result: (And64 n (Const64 <t> [c-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(isPowerOfTwo64(c)) { break } v.reset(OpAnd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c - 1) v.AddArg2(n, v0) return true } // match: (Mod64u <t> n (Const64 [-1<<63])) // result: (And64 n (Const64 <t> [1<<63-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != -1<<63 { break } v.reset(OpAnd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(1<<63 - 1) v.AddArg2(n, v0) return true } // match: (Mod64u <t> x (Const64 [c])) // cond: x.Op != OpConst64 && c > 0 && umagicOK64(c) // result: (Sub64 x (Mul64 <t> (Div64u <t> x (Const64 <t> [c])) (Const64 <t> [c]))) for { t := v.Type x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(x.Op != OpConst64 && c > 0 && umagicOK64(c)) { break } v.reset(OpSub64) v0 := b.NewValue0(v.Pos, OpMul64, t) v1 := b.NewValue0(v.Pos, OpDiv64u, t) v2 := b.NewValue0(v.Pos, OpConst64, t) v2.AuxInt = int64ToAuxInt(c) v1.AddArg2(x, v2) v0.AddArg2(v1, v2) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpMod8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Mod8 (Const8 [c]) (Const8 [d])) // cond: d != 0 // result: (Const8 [c % d]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c % d) return true } // match: (Mod8 <t> n (Const8 [c])) // cond: isNonNegative(n) && isPowerOfTwo8(c) // result: (And8 n (Const8 <t> [c-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(isNonNegative(n) && isPowerOfTwo8(c)) { break } v.reset(OpAnd8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c - 1) v.AddArg2(n, v0) return true } // match: (Mod8 <t> n (Const8 [c])) // cond: c < 0 && c != -1<<7 // result: (Mod8 <t> n (Const8 <t> [-c])) for { t := v.Type n := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(c < 0 && c != -1<<7) { break } v.reset(OpMod8) v.Type = t v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(-c) v.AddArg2(n, v0) return true } // match: (Mod8 <t> x (Const8 [c])) // cond: x.Op != OpConst8 && (c > 0 || c == -1<<7) // result: (Sub8 x (Mul8 <t> (Div8 <t> x (Const8 <t> [c])) (Const8 <t> [c]))) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(x.Op != OpConst8 && (c > 0 || c == -1<<7)) { break } v.reset(OpSub8) v0 := b.NewValue0(v.Pos, OpMul8, t) v1 := b.NewValue0(v.Pos, OpDiv8, t) v2 := b.NewValue0(v.Pos, OpConst8, t) v2.AuxInt = int8ToAuxInt(c) v1.AddArg2(x, v2) v0.AddArg2(v1, v2) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpMod8u(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Mod8u (Const8 [c]) (Const8 [d])) // cond: d != 0 // result: (Const8 [int8(uint8(c) % uint8(d))]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) if !(d != 0) { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(int8(uint8(c) % uint8(d))) return true } // match: (Mod8u <t> n (Const8 [c])) // cond: isPowerOfTwo8(c) // result: (And8 n (Const8 <t> [c-1])) for { t := v.Type n := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(isPowerOfTwo8(c)) { break } v.reset(OpAnd8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c - 1) v.AddArg2(n, v0) return true } // match: (Mod8u <t> x (Const8 [c])) // cond: x.Op != OpConst8 && c > 0 && umagicOK8( c) // result: (Sub8 x (Mul8 <t> (Div8u <t> x (Const8 <t> [c])) (Const8 <t> [c]))) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(x.Op != OpConst8 && c > 0 && umagicOK8(c)) { break } v.reset(OpSub8) v0 := b.NewValue0(v.Pos, OpMul8, t) v1 := b.NewValue0(v.Pos, OpDiv8u, t) v2 := b.NewValue0(v.Pos, OpConst8, t) v2.AuxInt = int8ToAuxInt(c) v1.AddArg2(x, v2) v0.AddArg2(v1, v2) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpMove(v *Value) bool { v_2 := v.Args[2] v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config // match: (Move {t} [n] dst1 src mem:(Zero {t} [n] dst2 _)) // cond: isSamePtr(src, dst2) // result: (Zero {t} [n] dst1 mem) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 src := v_1 mem := v_2 if mem.Op != OpZero || auxIntToInt64(mem.AuxInt) != n || auxToType(mem.Aux) != t { break } dst2 := mem.Args[0] if !(isSamePtr(src, dst2)) { break } v.reset(OpZero) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v.AddArg2(dst1, mem) return true } // match: (Move {t} [n] dst1 src mem:(VarDef (Zero {t} [n] dst0 _))) // cond: isSamePtr(src, dst0) // result: (Zero {t} [n] dst1 mem) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 src := v_1 mem := v_2 if mem.Op != OpVarDef { break } mem_0 := mem.Args[0] if mem_0.Op != OpZero || auxIntToInt64(mem_0.AuxInt) != n || auxToType(mem_0.Aux) != t { break } dst0 := mem_0.Args[0] if !(isSamePtr(src, dst0)) { break } v.reset(OpZero) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v.AddArg2(dst1, mem) return true } // match: (Move {t} [n] dst (Addr {sym} (SB)) mem) // cond: symIsROZero(sym) // result: (Zero {t} [n] dst mem) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst := v_0 if v_1.Op != OpAddr { break } sym := auxToSym(v_1.Aux) v_1_0 := v_1.Args[0] if v_1_0.Op != OpSB { break } mem := v_2 if !(symIsROZero(sym)) { break } v.reset(OpZero) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v.AddArg2(dst, mem) return true } // match: (Move {t1} [n] dst1 src1 store:(Store {t2} op:(OffPtr [o2] dst2) _ mem)) // cond: isSamePtr(dst1, dst2) && store.Uses == 1 && n >= o2 + t2.Size() && disjoint(src1, n, op, t2.Size()) && clobber(store) // result: (Move {t1} [n] dst1 src1 mem) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst1 := v_0 src1 := v_1 store := v_2 if store.Op != OpStore { break } t2 := auxToType(store.Aux) mem := store.Args[2] op := store.Args[0] if op.Op != OpOffPtr { break } o2 := auxIntToInt64(op.AuxInt) dst2 := op.Args[0] if !(isSamePtr(dst1, dst2) && store.Uses == 1 && n >= o2+t2.Size() && disjoint(src1, n, op, t2.Size()) && clobber(store)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t1) v.AddArg3(dst1, src1, mem) return true } // match: (Move {t} [n] dst1 src1 move:(Move {t} [n] dst2 _ mem)) // cond: move.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(move) // result: (Move {t} [n] dst1 src1 mem) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 src1 := v_1 move := v_2 if move.Op != OpMove || auxIntToInt64(move.AuxInt) != n || auxToType(move.Aux) != t { break } mem := move.Args[2] dst2 := move.Args[0] if !(move.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(move)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v.AddArg3(dst1, src1, mem) return true } // match: (Move {t} [n] dst1 src1 vardef:(VarDef {x} move:(Move {t} [n] dst2 _ mem))) // cond: move.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(move, vardef) // result: (Move {t} [n] dst1 src1 (VarDef {x} mem)) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 src1 := v_1 vardef := v_2 if vardef.Op != OpVarDef { break } x := auxToSym(vardef.Aux) move := vardef.Args[0] if move.Op != OpMove || auxIntToInt64(move.AuxInt) != n || auxToType(move.Aux) != t { break } mem := move.Args[2] dst2 := move.Args[0] if !(move.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(move, vardef)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v0 := b.NewValue0(v.Pos, OpVarDef, types.TypeMem) v0.Aux = symToAux(x) v0.AddArg(mem) v.AddArg3(dst1, src1, v0) return true } // match: (Move {t} [n] dst1 src1 zero:(Zero {t} [n] dst2 mem)) // cond: zero.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(zero) // result: (Move {t} [n] dst1 src1 mem) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 src1 := v_1 zero := v_2 if zero.Op != OpZero || auxIntToInt64(zero.AuxInt) != n || auxToType(zero.Aux) != t { break } mem := zero.Args[1] dst2 := zero.Args[0] if !(zero.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(zero)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v.AddArg3(dst1, src1, mem) return true } // match: (Move {t} [n] dst1 src1 vardef:(VarDef {x} zero:(Zero {t} [n] dst2 mem))) // cond: zero.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(zero, vardef) // result: (Move {t} [n] dst1 src1 (VarDef {x} mem)) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 src1 := v_1 vardef := v_2 if vardef.Op != OpVarDef { break } x := auxToSym(vardef.Aux) zero := vardef.Args[0] if zero.Op != OpZero || auxIntToInt64(zero.AuxInt) != n || auxToType(zero.Aux) != t { break } mem := zero.Args[1] dst2 := zero.Args[0] if !(zero.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && disjoint(src1, n, dst2, n) && clobber(zero, vardef)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v0 := b.NewValue0(v.Pos, OpVarDef, types.TypeMem) v0.Aux = symToAux(x) v0.AddArg(mem) v.AddArg3(dst1, src1, v0) return true } // match: (Move {t1} [n] dst p1 mem:(Store {t2} op2:(OffPtr <tt2> [o2] p2) d1 (Store {t3} op3:(OffPtr <tt3> [0] p3) d2 _))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && o2 == t3.Size() && n == t2.Size() + t3.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [0] dst) d2 mem)) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] op2 := mem.Args[0] if op2.Op != OpOffPtr { break } tt2 := op2.Type o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d1 := mem.Args[1] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t3 := auxToType(mem_2.Aux) d2 := mem_2.Args[1] op3 := mem_2.Args[0] if op3.Op != OpOffPtr { break } tt3 := op3.Type if auxIntToInt64(op3.AuxInt) != 0 { break } p3 := op3.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && o2 == t3.Size() && n == t2.Size()+t3.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(0) v2.AddArg(dst) v1.AddArg3(v2, d2, mem) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(Store {t2} op2:(OffPtr <tt2> [o2] p2) d1 (Store {t3} op3:(OffPtr <tt3> [o3] p3) d2 (Store {t4} op4:(OffPtr <tt4> [0] p4) d3 _)))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && o3 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size() + t3.Size() + t4.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Store {t4} (OffPtr <tt4> [0] dst) d3 mem))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] op2 := mem.Args[0] if op2.Op != OpOffPtr { break } tt2 := op2.Type o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d1 := mem.Args[1] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t3 := auxToType(mem_2.Aux) _ = mem_2.Args[2] op3 := mem_2.Args[0] if op3.Op != OpOffPtr { break } tt3 := op3.Type o3 := auxIntToInt64(op3.AuxInt) p3 := op3.Args[0] d2 := mem_2.Args[1] mem_2_2 := mem_2.Args[2] if mem_2_2.Op != OpStore { break } t4 := auxToType(mem_2_2.Aux) d3 := mem_2_2.Args[1] op4 := mem_2_2.Args[0] if op4.Op != OpOffPtr { break } tt4 := op4.Type if auxIntToInt64(op4.AuxInt) != 0 { break } p4 := op4.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && o3 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size()+t3.Size()+t4.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t4) v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) v4.AuxInt = int64ToAuxInt(0) v4.AddArg(dst) v3.AddArg3(v4, d3, mem) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(Store {t2} op2:(OffPtr <tt2> [o2] p2) d1 (Store {t3} op3:(OffPtr <tt3> [o3] p3) d2 (Store {t4} op4:(OffPtr <tt4> [o4] p4) d3 (Store {t5} op5:(OffPtr <tt5> [0] p5) d4 _))))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && o4 == t5.Size() && o3-o4 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size() + t3.Size() + t4.Size() + t5.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Store {t4} (OffPtr <tt4> [o4] dst) d3 (Store {t5} (OffPtr <tt5> [0] dst) d4 mem)))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] op2 := mem.Args[0] if op2.Op != OpOffPtr { break } tt2 := op2.Type o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d1 := mem.Args[1] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t3 := auxToType(mem_2.Aux) _ = mem_2.Args[2] op3 := mem_2.Args[0] if op3.Op != OpOffPtr { break } tt3 := op3.Type o3 := auxIntToInt64(op3.AuxInt) p3 := op3.Args[0] d2 := mem_2.Args[1] mem_2_2 := mem_2.Args[2] if mem_2_2.Op != OpStore { break } t4 := auxToType(mem_2_2.Aux) _ = mem_2_2.Args[2] op4 := mem_2_2.Args[0] if op4.Op != OpOffPtr { break } tt4 := op4.Type o4 := auxIntToInt64(op4.AuxInt) p4 := op4.Args[0] d3 := mem_2_2.Args[1] mem_2_2_2 := mem_2_2.Args[2] if mem_2_2_2.Op != OpStore { break } t5 := auxToType(mem_2_2_2.Aux) d4 := mem_2_2_2.Args[1] op5 := mem_2_2_2.Args[0] if op5.Op != OpOffPtr { break } tt5 := op5.Type if auxIntToInt64(op5.AuxInt) != 0 { break } p5 := op5.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && o4 == t5.Size() && o3-o4 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size()+t3.Size()+t4.Size()+t5.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t4) v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) v4.AuxInt = int64ToAuxInt(o4) v4.AddArg(dst) v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v5.Aux = typeToAux(t5) v6 := b.NewValue0(v.Pos, OpOffPtr, tt5) v6.AuxInt = int64ToAuxInt(0) v6.AddArg(dst) v5.AddArg3(v6, d4, mem) v3.AddArg3(v4, d3, v5) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} op2:(OffPtr <tt2> [o2] p2) d1 (Store {t3} op3:(OffPtr <tt3> [0] p3) d2 _)))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && o2 == t3.Size() && n == t2.Size() + t3.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [0] dst) d2 mem)) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpVarDef { break } mem_0 := mem.Args[0] if mem_0.Op != OpStore { break } t2 := auxToType(mem_0.Aux) _ = mem_0.Args[2] op2 := mem_0.Args[0] if op2.Op != OpOffPtr { break } tt2 := op2.Type o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d1 := mem_0.Args[1] mem_0_2 := mem_0.Args[2] if mem_0_2.Op != OpStore { break } t3 := auxToType(mem_0_2.Aux) d2 := mem_0_2.Args[1] op3 := mem_0_2.Args[0] if op3.Op != OpOffPtr { break } tt3 := op3.Type if auxIntToInt64(op3.AuxInt) != 0 { break } p3 := op3.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && o2 == t3.Size() && n == t2.Size()+t3.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(0) v2.AddArg(dst) v1.AddArg3(v2, d2, mem) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} op2:(OffPtr <tt2> [o2] p2) d1 (Store {t3} op3:(OffPtr <tt3> [o3] p3) d2 (Store {t4} op4:(OffPtr <tt4> [0] p4) d3 _))))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && o3 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size() + t3.Size() + t4.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Store {t4} (OffPtr <tt4> [0] dst) d3 mem))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpVarDef { break } mem_0 := mem.Args[0] if mem_0.Op != OpStore { break } t2 := auxToType(mem_0.Aux) _ = mem_0.Args[2] op2 := mem_0.Args[0] if op2.Op != OpOffPtr { break } tt2 := op2.Type o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d1 := mem_0.Args[1] mem_0_2 := mem_0.Args[2] if mem_0_2.Op != OpStore { break } t3 := auxToType(mem_0_2.Aux) _ = mem_0_2.Args[2] op3 := mem_0_2.Args[0] if op3.Op != OpOffPtr { break } tt3 := op3.Type o3 := auxIntToInt64(op3.AuxInt) p3 := op3.Args[0] d2 := mem_0_2.Args[1] mem_0_2_2 := mem_0_2.Args[2] if mem_0_2_2.Op != OpStore { break } t4 := auxToType(mem_0_2_2.Aux) d3 := mem_0_2_2.Args[1] op4 := mem_0_2_2.Args[0] if op4.Op != OpOffPtr { break } tt4 := op4.Type if auxIntToInt64(op4.AuxInt) != 0 { break } p4 := op4.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && o3 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size()+t3.Size()+t4.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t4) v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) v4.AuxInt = int64ToAuxInt(0) v4.AddArg(dst) v3.AddArg3(v4, d3, mem) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} op2:(OffPtr <tt2> [o2] p2) d1 (Store {t3} op3:(OffPtr <tt3> [o3] p3) d2 (Store {t4} op4:(OffPtr <tt4> [o4] p4) d3 (Store {t5} op5:(OffPtr <tt5> [0] p5) d4 _)))))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && o4 == t5.Size() && o3-o4 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size() + t3.Size() + t4.Size() + t5.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Store {t4} (OffPtr <tt4> [o4] dst) d3 (Store {t5} (OffPtr <tt5> [0] dst) d4 mem)))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpVarDef { break } mem_0 := mem.Args[0] if mem_0.Op != OpStore { break } t2 := auxToType(mem_0.Aux) _ = mem_0.Args[2] op2 := mem_0.Args[0] if op2.Op != OpOffPtr { break } tt2 := op2.Type o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d1 := mem_0.Args[1] mem_0_2 := mem_0.Args[2] if mem_0_2.Op != OpStore { break } t3 := auxToType(mem_0_2.Aux) _ = mem_0_2.Args[2] op3 := mem_0_2.Args[0] if op3.Op != OpOffPtr { break } tt3 := op3.Type o3 := auxIntToInt64(op3.AuxInt) p3 := op3.Args[0] d2 := mem_0_2.Args[1] mem_0_2_2 := mem_0_2.Args[2] if mem_0_2_2.Op != OpStore { break } t4 := auxToType(mem_0_2_2.Aux) _ = mem_0_2_2.Args[2] op4 := mem_0_2_2.Args[0] if op4.Op != OpOffPtr { break } tt4 := op4.Type o4 := auxIntToInt64(op4.AuxInt) p4 := op4.Args[0] d3 := mem_0_2_2.Args[1] mem_0_2_2_2 := mem_0_2_2.Args[2] if mem_0_2_2_2.Op != OpStore { break } t5 := auxToType(mem_0_2_2_2.Aux) d4 := mem_0_2_2_2.Args[1] op5 := mem_0_2_2_2.Args[0] if op5.Op != OpOffPtr { break } tt5 := op5.Type if auxIntToInt64(op5.AuxInt) != 0 { break } p5 := op5.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && o4 == t5.Size() && o3-o4 == t4.Size() && o2-o3 == t3.Size() && n == t2.Size()+t3.Size()+t4.Size()+t5.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t4) v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) v4.AuxInt = int64ToAuxInt(o4) v4.AddArg(dst) v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v5.Aux = typeToAux(t5) v6 := b.NewValue0(v.Pos, OpOffPtr, tt5) v6.AuxInt = int64ToAuxInt(0) v6.AddArg(dst) v5.AddArg3(v6, d4, mem) v3.AddArg3(v4, d3, v5) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(Store {t2} op2:(OffPtr <tt2> [o2] p2) d1 (Zero {t3} [n] p3 _))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && n >= o2 + t2.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Zero {t1} [n] dst mem)) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] op2 := mem.Args[0] if op2.Op != OpOffPtr { break } tt2 := op2.Type o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d1 := mem.Args[1] mem_2 := mem.Args[2] if mem_2.Op != OpZero || auxIntToInt64(mem_2.AuxInt) != n { break } t3 := auxToType(mem_2.Aux) p3 := mem_2.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && n >= o2+t2.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpZero, types.TypeMem) v1.AuxInt = int64ToAuxInt(n) v1.Aux = typeToAux(t1) v1.AddArg2(dst, mem) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(Store {t2} (OffPtr <tt2> [o2] p2) d1 (Store {t3} (OffPtr <tt3> [o3] p3) d2 (Zero {t4} [n] p4 _)))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && n >= o2 + t2.Size() && n >= o3 + t3.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Zero {t1} [n] dst mem))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] mem_0 := mem.Args[0] if mem_0.Op != OpOffPtr { break } tt2 := mem_0.Type o2 := auxIntToInt64(mem_0.AuxInt) p2 := mem_0.Args[0] d1 := mem.Args[1] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t3 := auxToType(mem_2.Aux) _ = mem_2.Args[2] mem_2_0 := mem_2.Args[0] if mem_2_0.Op != OpOffPtr { break } tt3 := mem_2_0.Type o3 := auxIntToInt64(mem_2_0.AuxInt) p3 := mem_2_0.Args[0] d2 := mem_2.Args[1] mem_2_2 := mem_2.Args[2] if mem_2_2.Op != OpZero || auxIntToInt64(mem_2_2.AuxInt) != n { break } t4 := auxToType(mem_2_2.Aux) p4 := mem_2_2.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && n >= o2+t2.Size() && n >= o3+t3.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpZero, types.TypeMem) v3.AuxInt = int64ToAuxInt(n) v3.Aux = typeToAux(t1) v3.AddArg2(dst, mem) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(Store {t2} (OffPtr <tt2> [o2] p2) d1 (Store {t3} (OffPtr <tt3> [o3] p3) d2 (Store {t4} (OffPtr <tt4> [o4] p4) d3 (Zero {t5} [n] p5 _))))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && n >= o2 + t2.Size() && n >= o3 + t3.Size() && n >= o4 + t4.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Store {t4} (OffPtr <tt4> [o4] dst) d3 (Zero {t1} [n] dst mem)))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] mem_0 := mem.Args[0] if mem_0.Op != OpOffPtr { break } tt2 := mem_0.Type o2 := auxIntToInt64(mem_0.AuxInt) p2 := mem_0.Args[0] d1 := mem.Args[1] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t3 := auxToType(mem_2.Aux) _ = mem_2.Args[2] mem_2_0 := mem_2.Args[0] if mem_2_0.Op != OpOffPtr { break } tt3 := mem_2_0.Type o3 := auxIntToInt64(mem_2_0.AuxInt) p3 := mem_2_0.Args[0] d2 := mem_2.Args[1] mem_2_2 := mem_2.Args[2] if mem_2_2.Op != OpStore { break } t4 := auxToType(mem_2_2.Aux) _ = mem_2_2.Args[2] mem_2_2_0 := mem_2_2.Args[0] if mem_2_2_0.Op != OpOffPtr { break } tt4 := mem_2_2_0.Type o4 := auxIntToInt64(mem_2_2_0.AuxInt) p4 := mem_2_2_0.Args[0] d3 := mem_2_2.Args[1] mem_2_2_2 := mem_2_2.Args[2] if mem_2_2_2.Op != OpZero || auxIntToInt64(mem_2_2_2.AuxInt) != n { break } t5 := auxToType(mem_2_2_2.Aux) p5 := mem_2_2_2.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && n >= o2+t2.Size() && n >= o3+t3.Size() && n >= o4+t4.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t4) v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) v4.AuxInt = int64ToAuxInt(o4) v4.AddArg(dst) v5 := b.NewValue0(v.Pos, OpZero, types.TypeMem) v5.AuxInt = int64ToAuxInt(n) v5.Aux = typeToAux(t1) v5.AddArg2(dst, mem) v3.AddArg3(v4, d3, v5) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(Store {t2} (OffPtr <tt2> [o2] p2) d1 (Store {t3} (OffPtr <tt3> [o3] p3) d2 (Store {t4} (OffPtr <tt4> [o4] p4) d3 (Store {t5} (OffPtr <tt5> [o5] p5) d4 (Zero {t6} [n] p6 _)))))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && isSamePtr(p5, p6) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && t6.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && n >= o2 + t2.Size() && n >= o3 + t3.Size() && n >= o4 + t4.Size() && n >= o5 + t5.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Store {t4} (OffPtr <tt4> [o4] dst) d3 (Store {t5} (OffPtr <tt5> [o5] dst) d4 (Zero {t1} [n] dst mem))))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] mem_0 := mem.Args[0] if mem_0.Op != OpOffPtr { break } tt2 := mem_0.Type o2 := auxIntToInt64(mem_0.AuxInt) p2 := mem_0.Args[0] d1 := mem.Args[1] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t3 := auxToType(mem_2.Aux) _ = mem_2.Args[2] mem_2_0 := mem_2.Args[0] if mem_2_0.Op != OpOffPtr { break } tt3 := mem_2_0.Type o3 := auxIntToInt64(mem_2_0.AuxInt) p3 := mem_2_0.Args[0] d2 := mem_2.Args[1] mem_2_2 := mem_2.Args[2] if mem_2_2.Op != OpStore { break } t4 := auxToType(mem_2_2.Aux) _ = mem_2_2.Args[2] mem_2_2_0 := mem_2_2.Args[0] if mem_2_2_0.Op != OpOffPtr { break } tt4 := mem_2_2_0.Type o4 := auxIntToInt64(mem_2_2_0.AuxInt) p4 := mem_2_2_0.Args[0] d3 := mem_2_2.Args[1] mem_2_2_2 := mem_2_2.Args[2] if mem_2_2_2.Op != OpStore { break } t5 := auxToType(mem_2_2_2.Aux) _ = mem_2_2_2.Args[2] mem_2_2_2_0 := mem_2_2_2.Args[0] if mem_2_2_2_0.Op != OpOffPtr { break } tt5 := mem_2_2_2_0.Type o5 := auxIntToInt64(mem_2_2_2_0.AuxInt) p5 := mem_2_2_2_0.Args[0] d4 := mem_2_2_2.Args[1] mem_2_2_2_2 := mem_2_2_2.Args[2] if mem_2_2_2_2.Op != OpZero || auxIntToInt64(mem_2_2_2_2.AuxInt) != n { break } t6 := auxToType(mem_2_2_2_2.Aux) p6 := mem_2_2_2_2.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && isSamePtr(p5, p6) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && t6.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && n >= o2+t2.Size() && n >= o3+t3.Size() && n >= o4+t4.Size() && n >= o5+t5.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t4) v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) v4.AuxInt = int64ToAuxInt(o4) v4.AddArg(dst) v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v5.Aux = typeToAux(t5) v6 := b.NewValue0(v.Pos, OpOffPtr, tt5) v6.AuxInt = int64ToAuxInt(o5) v6.AddArg(dst) v7 := b.NewValue0(v.Pos, OpZero, types.TypeMem) v7.AuxInt = int64ToAuxInt(n) v7.Aux = typeToAux(t1) v7.AddArg2(dst, mem) v5.AddArg3(v6, d4, v7) v3.AddArg3(v4, d3, v5) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} op2:(OffPtr <tt2> [o2] p2) d1 (Zero {t3} [n] p3 _)))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && n >= o2 + t2.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Zero {t1} [n] dst mem)) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpVarDef { break } mem_0 := mem.Args[0] if mem_0.Op != OpStore { break } t2 := auxToType(mem_0.Aux) _ = mem_0.Args[2] op2 := mem_0.Args[0] if op2.Op != OpOffPtr { break } tt2 := op2.Type o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d1 := mem_0.Args[1] mem_0_2 := mem_0.Args[2] if mem_0_2.Op != OpZero || auxIntToInt64(mem_0_2.AuxInt) != n { break } t3 := auxToType(mem_0_2.Aux) p3 := mem_0_2.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && registerizable(b, t2) && n >= o2+t2.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpZero, types.TypeMem) v1.AuxInt = int64ToAuxInt(n) v1.Aux = typeToAux(t1) v1.AddArg2(dst, mem) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} (OffPtr <tt2> [o2] p2) d1 (Store {t3} (OffPtr <tt3> [o3] p3) d2 (Zero {t4} [n] p4 _))))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && n >= o2 + t2.Size() && n >= o3 + t3.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Zero {t1} [n] dst mem))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpVarDef { break } mem_0 := mem.Args[0] if mem_0.Op != OpStore { break } t2 := auxToType(mem_0.Aux) _ = mem_0.Args[2] mem_0_0 := mem_0.Args[0] if mem_0_0.Op != OpOffPtr { break } tt2 := mem_0_0.Type o2 := auxIntToInt64(mem_0_0.AuxInt) p2 := mem_0_0.Args[0] d1 := mem_0.Args[1] mem_0_2 := mem_0.Args[2] if mem_0_2.Op != OpStore { break } t3 := auxToType(mem_0_2.Aux) _ = mem_0_2.Args[2] mem_0_2_0 := mem_0_2.Args[0] if mem_0_2_0.Op != OpOffPtr { break } tt3 := mem_0_2_0.Type o3 := auxIntToInt64(mem_0_2_0.AuxInt) p3 := mem_0_2_0.Args[0] d2 := mem_0_2.Args[1] mem_0_2_2 := mem_0_2.Args[2] if mem_0_2_2.Op != OpZero || auxIntToInt64(mem_0_2_2.AuxInt) != n { break } t4 := auxToType(mem_0_2_2.Aux) p4 := mem_0_2_2.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && n >= o2+t2.Size() && n >= o3+t3.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpZero, types.TypeMem) v3.AuxInt = int64ToAuxInt(n) v3.Aux = typeToAux(t1) v3.AddArg2(dst, mem) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} (OffPtr <tt2> [o2] p2) d1 (Store {t3} (OffPtr <tt3> [o3] p3) d2 (Store {t4} (OffPtr <tt4> [o4] p4) d3 (Zero {t5} [n] p5 _)))))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && n >= o2 + t2.Size() && n >= o3 + t3.Size() && n >= o4 + t4.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Store {t4} (OffPtr <tt4> [o4] dst) d3 (Zero {t1} [n] dst mem)))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpVarDef { break } mem_0 := mem.Args[0] if mem_0.Op != OpStore { break } t2 := auxToType(mem_0.Aux) _ = mem_0.Args[2] mem_0_0 := mem_0.Args[0] if mem_0_0.Op != OpOffPtr { break } tt2 := mem_0_0.Type o2 := auxIntToInt64(mem_0_0.AuxInt) p2 := mem_0_0.Args[0] d1 := mem_0.Args[1] mem_0_2 := mem_0.Args[2] if mem_0_2.Op != OpStore { break } t3 := auxToType(mem_0_2.Aux) _ = mem_0_2.Args[2] mem_0_2_0 := mem_0_2.Args[0] if mem_0_2_0.Op != OpOffPtr { break } tt3 := mem_0_2_0.Type o3 := auxIntToInt64(mem_0_2_0.AuxInt) p3 := mem_0_2_0.Args[0] d2 := mem_0_2.Args[1] mem_0_2_2 := mem_0_2.Args[2] if mem_0_2_2.Op != OpStore { break } t4 := auxToType(mem_0_2_2.Aux) _ = mem_0_2_2.Args[2] mem_0_2_2_0 := mem_0_2_2.Args[0] if mem_0_2_2_0.Op != OpOffPtr { break } tt4 := mem_0_2_2_0.Type o4 := auxIntToInt64(mem_0_2_2_0.AuxInt) p4 := mem_0_2_2_0.Args[0] d3 := mem_0_2_2.Args[1] mem_0_2_2_2 := mem_0_2_2.Args[2] if mem_0_2_2_2.Op != OpZero || auxIntToInt64(mem_0_2_2_2.AuxInt) != n { break } t5 := auxToType(mem_0_2_2_2.Aux) p5 := mem_0_2_2_2.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && n >= o2+t2.Size() && n >= o3+t3.Size() && n >= o4+t4.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t4) v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) v4.AuxInt = int64ToAuxInt(o4) v4.AddArg(dst) v5 := b.NewValue0(v.Pos, OpZero, types.TypeMem) v5.AuxInt = int64ToAuxInt(n) v5.Aux = typeToAux(t1) v5.AddArg2(dst, mem) v3.AddArg3(v4, d3, v5) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [n] dst p1 mem:(VarDef (Store {t2} (OffPtr <tt2> [o2] p2) d1 (Store {t3} (OffPtr <tt3> [o3] p3) d2 (Store {t4} (OffPtr <tt4> [o4] p4) d3 (Store {t5} (OffPtr <tt5> [o5] p5) d4 (Zero {t6} [n] p6 _))))))) // cond: isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && isSamePtr(p5, p6) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && t6.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && n >= o2 + t2.Size() && n >= o3 + t3.Size() && n >= o4 + t4.Size() && n >= o5 + t5.Size() // result: (Store {t2} (OffPtr <tt2> [o2] dst) d1 (Store {t3} (OffPtr <tt3> [o3] dst) d2 (Store {t4} (OffPtr <tt4> [o4] dst) d3 (Store {t5} (OffPtr <tt5> [o5] dst) d4 (Zero {t1} [n] dst mem))))) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 p1 := v_1 mem := v_2 if mem.Op != OpVarDef { break } mem_0 := mem.Args[0] if mem_0.Op != OpStore { break } t2 := auxToType(mem_0.Aux) _ = mem_0.Args[2] mem_0_0 := mem_0.Args[0] if mem_0_0.Op != OpOffPtr { break } tt2 := mem_0_0.Type o2 := auxIntToInt64(mem_0_0.AuxInt) p2 := mem_0_0.Args[0] d1 := mem_0.Args[1] mem_0_2 := mem_0.Args[2] if mem_0_2.Op != OpStore { break } t3 := auxToType(mem_0_2.Aux) _ = mem_0_2.Args[2] mem_0_2_0 := mem_0_2.Args[0] if mem_0_2_0.Op != OpOffPtr { break } tt3 := mem_0_2_0.Type o3 := auxIntToInt64(mem_0_2_0.AuxInt) p3 := mem_0_2_0.Args[0] d2 := mem_0_2.Args[1] mem_0_2_2 := mem_0_2.Args[2] if mem_0_2_2.Op != OpStore { break } t4 := auxToType(mem_0_2_2.Aux) _ = mem_0_2_2.Args[2] mem_0_2_2_0 := mem_0_2_2.Args[0] if mem_0_2_2_0.Op != OpOffPtr { break } tt4 := mem_0_2_2_0.Type o4 := auxIntToInt64(mem_0_2_2_0.AuxInt) p4 := mem_0_2_2_0.Args[0] d3 := mem_0_2_2.Args[1] mem_0_2_2_2 := mem_0_2_2.Args[2] if mem_0_2_2_2.Op != OpStore { break } t5 := auxToType(mem_0_2_2_2.Aux) _ = mem_0_2_2_2.Args[2] mem_0_2_2_2_0 := mem_0_2_2_2.Args[0] if mem_0_2_2_2_0.Op != OpOffPtr { break } tt5 := mem_0_2_2_2_0.Type o5 := auxIntToInt64(mem_0_2_2_2_0.AuxInt) p5 := mem_0_2_2_2_0.Args[0] d4 := mem_0_2_2_2.Args[1] mem_0_2_2_2_2 := mem_0_2_2_2.Args[2] if mem_0_2_2_2_2.Op != OpZero || auxIntToInt64(mem_0_2_2_2_2.AuxInt) != n { break } t6 := auxToType(mem_0_2_2_2_2.Aux) p6 := mem_0_2_2_2_2.Args[0] if !(isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && isSamePtr(p5, p6) && t2.Alignment() <= t1.Alignment() && t3.Alignment() <= t1.Alignment() && t4.Alignment() <= t1.Alignment() && t5.Alignment() <= t1.Alignment() && t6.Alignment() <= t1.Alignment() && registerizable(b, t2) && registerizable(b, t3) && registerizable(b, t4) && registerizable(b, t5) && n >= o2+t2.Size() && n >= o3+t3.Size() && n >= o4+t4.Size() && n >= o5+t5.Size()) { break } v.reset(OpStore) v.Aux = typeToAux(t2) v0 := b.NewValue0(v.Pos, OpOffPtr, tt2) v0.AuxInt = int64ToAuxInt(o2) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpOffPtr, tt3) v2.AuxInt = int64ToAuxInt(o3) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t4) v4 := b.NewValue0(v.Pos, OpOffPtr, tt4) v4.AuxInt = int64ToAuxInt(o4) v4.AddArg(dst) v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v5.Aux = typeToAux(t5) v6 := b.NewValue0(v.Pos, OpOffPtr, tt5) v6.AuxInt = int64ToAuxInt(o5) v6.AddArg(dst) v7 := b.NewValue0(v.Pos, OpZero, types.TypeMem) v7.AuxInt = int64ToAuxInt(n) v7.Aux = typeToAux(t1) v7.AddArg2(dst, mem) v5.AddArg3(v6, d4, v7) v3.AddArg3(v4, d3, v5) v1.AddArg3(v2, d2, v3) v.AddArg3(v0, d1, v1) return true } // match: (Move {t1} [s] dst tmp1 midmem:(Move {t2} [s] tmp2 src _)) // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) // result: (Move {t1} [s] dst src midmem) for { s := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 tmp1 := v_1 midmem := v_2 if midmem.Op != OpMove || auxIntToInt64(midmem.AuxInt) != s { break } t2 := auxToType(midmem.Aux) src := midmem.Args[1] tmp2 := midmem.Args[0] if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(s) v.Aux = typeToAux(t1) v.AddArg3(dst, src, midmem) return true } // match: (Move {t1} [s] dst tmp1 midmem:(VarDef (Move {t2} [s] tmp2 src _))) // cond: t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config)) // result: (Move {t1} [s] dst src midmem) for { s := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) dst := v_0 tmp1 := v_1 midmem := v_2 if midmem.Op != OpVarDef { break } midmem_0 := midmem.Args[0] if midmem_0.Op != OpMove || auxIntToInt64(midmem_0.AuxInt) != s { break } t2 := auxToType(midmem_0.Aux) src := midmem_0.Args[1] tmp2 := midmem_0.Args[0] if !(t1.Compare(t2) == types.CMPeq && isSamePtr(tmp1, tmp2) && isStackPtr(src) && disjoint(src, s, tmp2, s) && (disjoint(src, s, dst, s) || isInlinableMemmove(dst, src, s, config))) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(s) v.Aux = typeToAux(t1) v.AddArg3(dst, src, midmem) return true } // match: (Move dst src mem) // cond: isSamePtr(dst, src) // result: mem for { dst := v_0 src := v_1 mem := v_2 if !(isSamePtr(dst, src)) { break } v.copyOf(mem) return true } return false } func rewriteValuegeneric_OpMul16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Mul16 (Const16 [c]) (Const16 [d])) // result: (Const16 [c*d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c * d) return true } break } // match: (Mul16 (Const16 [1]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 1 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Mul16 (Const16 [-1]) x) // result: (Neg16 x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != -1 { continue } x := v_1 v.reset(OpNeg16) v.AddArg(x) return true } break } // match: (Mul16 <t> n (Const16 [c])) // cond: isPowerOfTwo16(c) // result: (Lsh16x64 <t> n (Const64 <typ.UInt64> [log16(c)])) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpConst16 { continue } c := auxIntToInt16(v_1.AuxInt) if !(isPowerOfTwo16(c)) { continue } v.reset(OpLsh16x64) v.Type = t v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log16(c)) v.AddArg2(n, v0) return true } break } // match: (Mul16 <t> n (Const16 [c])) // cond: t.IsSigned() && isPowerOfTwo16(-c) // result: (Neg16 (Lsh16x64 <t> n (Const64 <typ.UInt64> [log16(-c)]))) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpConst16 { continue } c := auxIntToInt16(v_1.AuxInt) if !(t.IsSigned() && isPowerOfTwo16(-c)) { continue } v.reset(OpNeg16) v0 := b.NewValue0(v.Pos, OpLsh16x64, t) v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v1.AuxInt = int64ToAuxInt(log16(-c)) v0.AddArg2(n, v1) v.AddArg(v0) return true } break } // match: (Mul16 (Const16 [0]) _) // result: (Const16 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { continue } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } break } // match: (Mul16 (Const16 <t> [c]) (Mul16 (Const16 <t> [d]) x)) // result: (Mul16 (Const16 <t> [c*d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpMul16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 || v_1_0.Type != t { continue } d := auxIntToInt16(v_1_0.AuxInt) x := v_1_1 v.reset(OpMul16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c * d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpMul32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Mul32 (Const32 [c]) (Const32 [d])) // result: (Const32 [c*d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c * d) return true } break } // match: (Mul32 (Const32 [1]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 1 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Mul32 (Const32 [-1]) x) // result: (Neg32 x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != -1 { continue } x := v_1 v.reset(OpNeg32) v.AddArg(x) return true } break } // match: (Mul32 <t> n (Const32 [c])) // cond: isPowerOfTwo32(c) // result: (Lsh32x64 <t> n (Const64 <typ.UInt64> [log32(c)])) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpConst32 { continue } c := auxIntToInt32(v_1.AuxInt) if !(isPowerOfTwo32(c)) { continue } v.reset(OpLsh32x64) v.Type = t v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log32(c)) v.AddArg2(n, v0) return true } break } // match: (Mul32 <t> n (Const32 [c])) // cond: t.IsSigned() && isPowerOfTwo32(-c) // result: (Neg32 (Lsh32x64 <t> n (Const64 <typ.UInt64> [log32(-c)]))) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpConst32 { continue } c := auxIntToInt32(v_1.AuxInt) if !(t.IsSigned() && isPowerOfTwo32(-c)) { continue } v.reset(OpNeg32) v0 := b.NewValue0(v.Pos, OpLsh32x64, t) v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v1.AuxInt = int64ToAuxInt(log32(-c)) v0.AddArg2(n, v1) v.AddArg(v0) return true } break } // match: (Mul32 (Const32 <t> [c]) (Add32 <t> (Const32 <t> [d]) x)) // result: (Add32 (Const32 <t> [c*d]) (Mul32 <t> (Const32 <t> [c]) x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpAdd32 || v_1.Type != t { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) x := v_1_1 v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c * d) v1 := b.NewValue0(v.Pos, OpMul32, t) v2 := b.NewValue0(v.Pos, OpConst32, t) v2.AuxInt = int32ToAuxInt(c) v1.AddArg2(v2, x) v.AddArg2(v0, v1) return true } } break } // match: (Mul32 (Const32 [0]) _) // result: (Const32 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { continue } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } break } // match: (Mul32 (Const32 <t> [c]) (Mul32 (Const32 <t> [d]) x)) // result: (Mul32 (Const32 <t> [c*d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) x := v_1_1 v.reset(OpMul32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c * d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpMul32F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Mul32F (Const32F [c]) (Const32F [d])) // cond: c*d == c*d // result: (Const32F [c*d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32F { continue } c := auxIntToFloat32(v_0.AuxInt) if v_1.Op != OpConst32F { continue } d := auxIntToFloat32(v_1.AuxInt) if !(c*d == c*d) { continue } v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(c * d) return true } break } // match: (Mul32F x (Const32F [1])) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpConst32F || auxIntToFloat32(v_1.AuxInt) != 1 { continue } v.copyOf(x) return true } break } // match: (Mul32F x (Const32F [-1])) // result: (Neg32F x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpConst32F || auxIntToFloat32(v_1.AuxInt) != -1 { continue } v.reset(OpNeg32F) v.AddArg(x) return true } break } // match: (Mul32F x (Const32F [2])) // result: (Add32F x x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpConst32F || auxIntToFloat32(v_1.AuxInt) != 2 { continue } v.reset(OpAdd32F) v.AddArg2(x, x) return true } break } return false } func rewriteValuegeneric_OpMul64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Mul64 (Const64 [c]) (Const64 [d])) // result: (Const64 [c*d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c * d) return true } break } // match: (Mul64 (Const64 [1]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 1 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Mul64 (Const64 [-1]) x) // result: (Neg64 x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != -1 { continue } x := v_1 v.reset(OpNeg64) v.AddArg(x) return true } break } // match: (Mul64 <t> n (Const64 [c])) // cond: isPowerOfTwo64(c) // result: (Lsh64x64 <t> n (Const64 <typ.UInt64> [log64(c)])) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1.AuxInt) if !(isPowerOfTwo64(c)) { continue } v.reset(OpLsh64x64) v.Type = t v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log64(c)) v.AddArg2(n, v0) return true } break } // match: (Mul64 <t> n (Const64 [c])) // cond: t.IsSigned() && isPowerOfTwo64(-c) // result: (Neg64 (Lsh64x64 <t> n (Const64 <typ.UInt64> [log64(-c)]))) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpConst64 { continue } c := auxIntToInt64(v_1.AuxInt) if !(t.IsSigned() && isPowerOfTwo64(-c)) { continue } v.reset(OpNeg64) v0 := b.NewValue0(v.Pos, OpLsh64x64, t) v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v1.AuxInt = int64ToAuxInt(log64(-c)) v0.AddArg2(n, v1) v.AddArg(v0) return true } break } // match: (Mul64 (Const64 <t> [c]) (Add64 <t> (Const64 <t> [d]) x)) // result: (Add64 (Const64 <t> [c*d]) (Mul64 <t> (Const64 <t> [c]) x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpAdd64 || v_1.Type != t { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c * d) v1 := b.NewValue0(v.Pos, OpMul64, t) v2 := b.NewValue0(v.Pos, OpConst64, t) v2.AuxInt = int64ToAuxInt(c) v1.AddArg2(v2, x) v.AddArg2(v0, v1) return true } } break } // match: (Mul64 (Const64 [0]) _) // result: (Const64 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { continue } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } break } // match: (Mul64 (Const64 <t> [c]) (Mul64 (Const64 <t> [d]) x)) // result: (Mul64 (Const64 <t> [c*d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpMul64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 v.reset(OpMul64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c * d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpMul64F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Mul64F (Const64F [c]) (Const64F [d])) // cond: c*d == c*d // result: (Const64F [c*d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64F { continue } c := auxIntToFloat64(v_0.AuxInt) if v_1.Op != OpConst64F { continue } d := auxIntToFloat64(v_1.AuxInt) if !(c*d == c*d) { continue } v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(c * d) return true } break } // match: (Mul64F x (Const64F [1])) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpConst64F || auxIntToFloat64(v_1.AuxInt) != 1 { continue } v.copyOf(x) return true } break } // match: (Mul64F x (Const64F [-1])) // result: (Neg64F x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpConst64F || auxIntToFloat64(v_1.AuxInt) != -1 { continue } v.reset(OpNeg64F) v.AddArg(x) return true } break } // match: (Mul64F x (Const64F [2])) // result: (Add64F x x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpConst64F || auxIntToFloat64(v_1.AuxInt) != 2 { continue } v.reset(OpAdd64F) v.AddArg2(x, x) return true } break } return false } func rewriteValuegeneric_OpMul8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Mul8 (Const8 [c]) (Const8 [d])) // result: (Const8 [c*d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c * d) return true } break } // match: (Mul8 (Const8 [1]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 1 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Mul8 (Const8 [-1]) x) // result: (Neg8 x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != -1 { continue } x := v_1 v.reset(OpNeg8) v.AddArg(x) return true } break } // match: (Mul8 <t> n (Const8 [c])) // cond: isPowerOfTwo8(c) // result: (Lsh8x64 <t> n (Const64 <typ.UInt64> [log8(c)])) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpConst8 { continue } c := auxIntToInt8(v_1.AuxInt) if !(isPowerOfTwo8(c)) { continue } v.reset(OpLsh8x64) v.Type = t v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(log8(c)) v.AddArg2(n, v0) return true } break } // match: (Mul8 <t> n (Const8 [c])) // cond: t.IsSigned() && isPowerOfTwo8(-c) // result: (Neg8 (Lsh8x64 <t> n (Const64 <typ.UInt64> [log8(-c)]))) for { t := v.Type for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpConst8 { continue } c := auxIntToInt8(v_1.AuxInt) if !(t.IsSigned() && isPowerOfTwo8(-c)) { continue } v.reset(OpNeg8) v0 := b.NewValue0(v.Pos, OpLsh8x64, t) v1 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v1.AuxInt = int64ToAuxInt(log8(-c)) v0.AddArg2(n, v1) v.AddArg(v0) return true } break } // match: (Mul8 (Const8 [0]) _) // result: (Const8 [0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { continue } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } break } // match: (Mul8 (Const8 <t> [c]) (Mul8 (Const8 <t> [d]) x)) // result: (Mul8 (Const8 <t> [c*d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpMul8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 || v_1_0.Type != t { continue } d := auxIntToInt8(v_1_0.AuxInt) x := v_1_1 v.reset(OpMul8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c * d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpNeg16(v *Value) bool { v_0 := v.Args[0] b := v.Block // match: (Neg16 (Const16 [c])) // result: (Const16 [-c]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(-c) return true } // match: (Neg16 (Sub16 x y)) // result: (Sub16 y x) for { if v_0.Op != OpSub16 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpSub16) v.AddArg2(y, x) return true } // match: (Neg16 (Neg16 x)) // result: x for { if v_0.Op != OpNeg16 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Neg16 <t> (Com16 x)) // result: (Add16 (Const16 <t> [1]) x) for { t := v.Type if v_0.Op != OpCom16 { break } x := v_0.Args[0] v.reset(OpAdd16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(1) v.AddArg2(v0, x) return true } return false } func rewriteValuegeneric_OpNeg32(v *Value) bool { v_0 := v.Args[0] b := v.Block // match: (Neg32 (Const32 [c])) // result: (Const32 [-c]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(-c) return true } // match: (Neg32 (Sub32 x y)) // result: (Sub32 y x) for { if v_0.Op != OpSub32 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpSub32) v.AddArg2(y, x) return true } // match: (Neg32 (Neg32 x)) // result: x for { if v_0.Op != OpNeg32 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Neg32 <t> (Com32 x)) // result: (Add32 (Const32 <t> [1]) x) for { t := v.Type if v_0.Op != OpCom32 { break } x := v_0.Args[0] v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(1) v.AddArg2(v0, x) return true } return false } func rewriteValuegeneric_OpNeg32F(v *Value) bool { v_0 := v.Args[0] // match: (Neg32F (Const32F [c])) // cond: c != 0 // result: (Const32F [-c]) for { if v_0.Op != OpConst32F { break } c := auxIntToFloat32(v_0.AuxInt) if !(c != 0) { break } v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(-c) return true } return false } func rewriteValuegeneric_OpNeg64(v *Value) bool { v_0 := v.Args[0] b := v.Block // match: (Neg64 (Const64 [c])) // result: (Const64 [-c]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(-c) return true } // match: (Neg64 (Sub64 x y)) // result: (Sub64 y x) for { if v_0.Op != OpSub64 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpSub64) v.AddArg2(y, x) return true } // match: (Neg64 (Neg64 x)) // result: x for { if v_0.Op != OpNeg64 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Neg64 <t> (Com64 x)) // result: (Add64 (Const64 <t> [1]) x) for { t := v.Type if v_0.Op != OpCom64 { break } x := v_0.Args[0] v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(1) v.AddArg2(v0, x) return true } return false } func rewriteValuegeneric_OpNeg64F(v *Value) bool { v_0 := v.Args[0] // match: (Neg64F (Const64F [c])) // cond: c != 0 // result: (Const64F [-c]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) if !(c != 0) { break } v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(-c) return true } return false } func rewriteValuegeneric_OpNeg8(v *Value) bool { v_0 := v.Args[0] b := v.Block // match: (Neg8 (Const8 [c])) // result: (Const8 [-c]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(-c) return true } // match: (Neg8 (Sub8 x y)) // result: (Sub8 y x) for { if v_0.Op != OpSub8 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpSub8) v.AddArg2(y, x) return true } // match: (Neg8 (Neg8 x)) // result: x for { if v_0.Op != OpNeg8 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Neg8 <t> (Com8 x)) // result: (Add8 (Const8 <t> [1]) x) for { t := v.Type if v_0.Op != OpCom8 { break } x := v_0.Args[0] v.reset(OpAdd8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(1) v.AddArg2(v0, x) return true } return false } func rewriteValuegeneric_OpNeq16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Neq16 x x) // result: (ConstBool [false]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } // match: (Neq16 (Const16 <t> [c]) (Add16 (Const16 <t> [d]) x)) // result: (Neq16 (Const16 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpAdd16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 || v_1_0.Type != t { continue } d := auxIntToInt16(v_1_0.AuxInt) x := v_1_1 v.reset(OpNeq16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c - d) v.AddArg2(v0, x) return true } } break } // match: (Neq16 (Const16 [c]) (Const16 [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } // match: (Neq16 n (Lsh16x64 (Rsh16x64 (Add16 <t> n (Rsh16Ux64 <t> (Rsh16x64 <t> n (Const64 <typ.UInt64> [15])) (Const64 <typ.UInt64> [kbar]))) (Const64 <typ.UInt64> [k])) (Const64 <typ.UInt64> [k])) ) // cond: k > 0 && k < 15 && kbar == 16 - k // result: (Neq16 (And16 <t> n (Const16 <t> [1<<uint(k)-1])) (Const16 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpLsh16x64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpRsh16x64 { continue } _ = v_1_0.Args[1] v_1_0_0 := v_1_0.Args[0] if v_1_0_0.Op != OpAdd16 { continue } t := v_1_0_0.Type _ = v_1_0_0.Args[1] v_1_0_0_0 := v_1_0_0.Args[0] v_1_0_0_1 := v_1_0_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0_0_0, v_1_0_0_1 = _i1+1, v_1_0_0_1, v_1_0_0_0 { if n != v_1_0_0_0 || v_1_0_0_1.Op != OpRsh16Ux64 || v_1_0_0_1.Type != t { continue } _ = v_1_0_0_1.Args[1] v_1_0_0_1_0 := v_1_0_0_1.Args[0] if v_1_0_0_1_0.Op != OpRsh16x64 || v_1_0_0_1_0.Type != t { continue } _ = v_1_0_0_1_0.Args[1] if n != v_1_0_0_1_0.Args[0] { continue } v_1_0_0_1_0_1 := v_1_0_0_1_0.Args[1] if v_1_0_0_1_0_1.Op != OpConst64 || v_1_0_0_1_0_1.Type != typ.UInt64 || auxIntToInt64(v_1_0_0_1_0_1.AuxInt) != 15 { continue } v_1_0_0_1_1 := v_1_0_0_1.Args[1] if v_1_0_0_1_1.Op != OpConst64 || v_1_0_0_1_1.Type != typ.UInt64 { continue } kbar := auxIntToInt64(v_1_0_0_1_1.AuxInt) v_1_0_1 := v_1_0.Args[1] if v_1_0_1.Op != OpConst64 || v_1_0_1.Type != typ.UInt64 { continue } k := auxIntToInt64(v_1_0_1.AuxInt) v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != typ.UInt64 || auxIntToInt64(v_1_1.AuxInt) != k || !(k > 0 && k < 15 && kbar == 16-k) { continue } v.reset(OpNeq16) v0 := b.NewValue0(v.Pos, OpAnd16, t) v1 := b.NewValue0(v.Pos, OpConst16, t) v1.AuxInt = int16ToAuxInt(1<<uint(k) - 1) v0.AddArg2(n, v1) v2 := b.NewValue0(v.Pos, OpConst16, t) v2.AuxInt = int16ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } // match: (Neq16 s:(Sub16 x y) (Const16 [0])) // cond: s.Uses == 1 // result: (Neq16 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { s := v_0 if s.Op != OpSub16 { continue } y := s.Args[1] x := s.Args[0] if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != 0 || !(s.Uses == 1) { continue } v.reset(OpNeq16) v.AddArg2(x, y) return true } break } // match: (Neq16 (And16 <t> x (Const16 <t> [y])) (Const16 <t> [y])) // cond: oneBit16(y) // result: (Eq16 (And16 <t> x (Const16 <t> [y])) (Const16 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd16 { continue } t := v_0.Type _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst16 || v_0_1.Type != t { continue } y := auxIntToInt16(v_0_1.AuxInt) if v_1.Op != OpConst16 || v_1.Type != t || auxIntToInt16(v_1.AuxInt) != y || !(oneBit16(y)) { continue } v.reset(OpEq16) v0 := b.NewValue0(v.Pos, OpAnd16, t) v1 := b.NewValue0(v.Pos, OpConst16, t) v1.AuxInt = int16ToAuxInt(y) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst16, t) v2.AuxInt = int16ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } return false } func rewriteValuegeneric_OpNeq32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Neq32 x x) // result: (ConstBool [false]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } // match: (Neq32 (Const32 <t> [c]) (Add32 (Const32 <t> [d]) x)) // result: (Neq32 (Const32 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpAdd32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) x := v_1_1 v.reset(OpNeq32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c - d) v.AddArg2(v0, x) return true } } break } // match: (Neq32 (Const32 [c]) (Const32 [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } // match: (Neq32 n (Lsh32x64 (Rsh32x64 (Add32 <t> n (Rsh32Ux64 <t> (Rsh32x64 <t> n (Const64 <typ.UInt64> [31])) (Const64 <typ.UInt64> [kbar]))) (Const64 <typ.UInt64> [k])) (Const64 <typ.UInt64> [k])) ) // cond: k > 0 && k < 31 && kbar == 32 - k // result: (Neq32 (And32 <t> n (Const32 <t> [1<<uint(k)-1])) (Const32 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpLsh32x64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpRsh32x64 { continue } _ = v_1_0.Args[1] v_1_0_0 := v_1_0.Args[0] if v_1_0_0.Op != OpAdd32 { continue } t := v_1_0_0.Type _ = v_1_0_0.Args[1] v_1_0_0_0 := v_1_0_0.Args[0] v_1_0_0_1 := v_1_0_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0_0_0, v_1_0_0_1 = _i1+1, v_1_0_0_1, v_1_0_0_0 { if n != v_1_0_0_0 || v_1_0_0_1.Op != OpRsh32Ux64 || v_1_0_0_1.Type != t { continue } _ = v_1_0_0_1.Args[1] v_1_0_0_1_0 := v_1_0_0_1.Args[0] if v_1_0_0_1_0.Op != OpRsh32x64 || v_1_0_0_1_0.Type != t { continue } _ = v_1_0_0_1_0.Args[1] if n != v_1_0_0_1_0.Args[0] { continue } v_1_0_0_1_0_1 := v_1_0_0_1_0.Args[1] if v_1_0_0_1_0_1.Op != OpConst64 || v_1_0_0_1_0_1.Type != typ.UInt64 || auxIntToInt64(v_1_0_0_1_0_1.AuxInt) != 31 { continue } v_1_0_0_1_1 := v_1_0_0_1.Args[1] if v_1_0_0_1_1.Op != OpConst64 || v_1_0_0_1_1.Type != typ.UInt64 { continue } kbar := auxIntToInt64(v_1_0_0_1_1.AuxInt) v_1_0_1 := v_1_0.Args[1] if v_1_0_1.Op != OpConst64 || v_1_0_1.Type != typ.UInt64 { continue } k := auxIntToInt64(v_1_0_1.AuxInt) v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != typ.UInt64 || auxIntToInt64(v_1_1.AuxInt) != k || !(k > 0 && k < 31 && kbar == 32-k) { continue } v.reset(OpNeq32) v0 := b.NewValue0(v.Pos, OpAnd32, t) v1 := b.NewValue0(v.Pos, OpConst32, t) v1.AuxInt = int32ToAuxInt(1<<uint(k) - 1) v0.AddArg2(n, v1) v2 := b.NewValue0(v.Pos, OpConst32, t) v2.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } // match: (Neq32 s:(Sub32 x y) (Const32 [0])) // cond: s.Uses == 1 // result: (Neq32 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { s := v_0 if s.Op != OpSub32 { continue } y := s.Args[1] x := s.Args[0] if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != 0 || !(s.Uses == 1) { continue } v.reset(OpNeq32) v.AddArg2(x, y) return true } break } // match: (Neq32 (And32 <t> x (Const32 <t> [y])) (Const32 <t> [y])) // cond: oneBit32(y) // result: (Eq32 (And32 <t> x (Const32 <t> [y])) (Const32 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd32 { continue } t := v_0.Type _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst32 || v_0_1.Type != t { continue } y := auxIntToInt32(v_0_1.AuxInt) if v_1.Op != OpConst32 || v_1.Type != t || auxIntToInt32(v_1.AuxInt) != y || !(oneBit32(y)) { continue } v.reset(OpEq32) v0 := b.NewValue0(v.Pos, OpAnd32, t) v1 := b.NewValue0(v.Pos, OpConst32, t) v1.AuxInt = int32ToAuxInt(y) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst32, t) v2.AuxInt = int32ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } return false } func rewriteValuegeneric_OpNeq32F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Neq32F (Const32F [c]) (Const32F [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32F { continue } c := auxIntToFloat32(v_0.AuxInt) if v_1.Op != OpConst32F { continue } d := auxIntToFloat32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } return false } func rewriteValuegeneric_OpNeq64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Neq64 x x) // result: (ConstBool [false]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } // match: (Neq64 (Const64 <t> [c]) (Add64 (Const64 <t> [d]) x)) // result: (Neq64 (Const64 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpAdd64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 v.reset(OpNeq64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c - d) v.AddArg2(v0, x) return true } } break } // match: (Neq64 (Const64 [c]) (Const64 [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } // match: (Neq64 n (Lsh64x64 (Rsh64x64 (Add64 <t> n (Rsh64Ux64 <t> (Rsh64x64 <t> n (Const64 <typ.UInt64> [63])) (Const64 <typ.UInt64> [kbar]))) (Const64 <typ.UInt64> [k])) (Const64 <typ.UInt64> [k])) ) // cond: k > 0 && k < 63 && kbar == 64 - k // result: (Neq64 (And64 <t> n (Const64 <t> [1<<uint(k)-1])) (Const64 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpLsh64x64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpRsh64x64 { continue } _ = v_1_0.Args[1] v_1_0_0 := v_1_0.Args[0] if v_1_0_0.Op != OpAdd64 { continue } t := v_1_0_0.Type _ = v_1_0_0.Args[1] v_1_0_0_0 := v_1_0_0.Args[0] v_1_0_0_1 := v_1_0_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0_0_0, v_1_0_0_1 = _i1+1, v_1_0_0_1, v_1_0_0_0 { if n != v_1_0_0_0 || v_1_0_0_1.Op != OpRsh64Ux64 || v_1_0_0_1.Type != t { continue } _ = v_1_0_0_1.Args[1] v_1_0_0_1_0 := v_1_0_0_1.Args[0] if v_1_0_0_1_0.Op != OpRsh64x64 || v_1_0_0_1_0.Type != t { continue } _ = v_1_0_0_1_0.Args[1] if n != v_1_0_0_1_0.Args[0] { continue } v_1_0_0_1_0_1 := v_1_0_0_1_0.Args[1] if v_1_0_0_1_0_1.Op != OpConst64 || v_1_0_0_1_0_1.Type != typ.UInt64 || auxIntToInt64(v_1_0_0_1_0_1.AuxInt) != 63 { continue } v_1_0_0_1_1 := v_1_0_0_1.Args[1] if v_1_0_0_1_1.Op != OpConst64 || v_1_0_0_1_1.Type != typ.UInt64 { continue } kbar := auxIntToInt64(v_1_0_0_1_1.AuxInt) v_1_0_1 := v_1_0.Args[1] if v_1_0_1.Op != OpConst64 || v_1_0_1.Type != typ.UInt64 { continue } k := auxIntToInt64(v_1_0_1.AuxInt) v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != typ.UInt64 || auxIntToInt64(v_1_1.AuxInt) != k || !(k > 0 && k < 63 && kbar == 64-k) { continue } v.reset(OpNeq64) v0 := b.NewValue0(v.Pos, OpAnd64, t) v1 := b.NewValue0(v.Pos, OpConst64, t) v1.AuxInt = int64ToAuxInt(1<<uint(k) - 1) v0.AddArg2(n, v1) v2 := b.NewValue0(v.Pos, OpConst64, t) v2.AuxInt = int64ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } // match: (Neq64 s:(Sub64 x y) (Const64 [0])) // cond: s.Uses == 1 // result: (Neq64 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { s := v_0 if s.Op != OpSub64 { continue } y := s.Args[1] x := s.Args[0] if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 || !(s.Uses == 1) { continue } v.reset(OpNeq64) v.AddArg2(x, y) return true } break } // match: (Neq64 (And64 <t> x (Const64 <t> [y])) (Const64 <t> [y])) // cond: oneBit64(y) // result: (Eq64 (And64 <t> x (Const64 <t> [y])) (Const64 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd64 { continue } t := v_0.Type _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst64 || v_0_1.Type != t { continue } y := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 || v_1.Type != t || auxIntToInt64(v_1.AuxInt) != y || !(oneBit64(y)) { continue } v.reset(OpEq64) v0 := b.NewValue0(v.Pos, OpAnd64, t) v1 := b.NewValue0(v.Pos, OpConst64, t) v1.AuxInt = int64ToAuxInt(y) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst64, t) v2.AuxInt = int64ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } return false } func rewriteValuegeneric_OpNeq64F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Neq64F (Const64F [c]) (Const64F [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64F { continue } c := auxIntToFloat64(v_0.AuxInt) if v_1.Op != OpConst64F { continue } d := auxIntToFloat64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } return false } func rewriteValuegeneric_OpNeq8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Neq8 x x) // result: (ConstBool [false]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } // match: (Neq8 (Const8 <t> [c]) (Add8 (Const8 <t> [d]) x)) // result: (Neq8 (Const8 <t> [c-d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpAdd8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 || v_1_0.Type != t { continue } d := auxIntToInt8(v_1_0.AuxInt) x := v_1_1 v.reset(OpNeq8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c - d) v.AddArg2(v0, x) return true } } break } // match: (Neq8 (Const8 [c]) (Const8 [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } // match: (Neq8 n (Lsh8x64 (Rsh8x64 (Add8 <t> n (Rsh8Ux64 <t> (Rsh8x64 <t> n (Const64 <typ.UInt64> [ 7])) (Const64 <typ.UInt64> [kbar]))) (Const64 <typ.UInt64> [k])) (Const64 <typ.UInt64> [k])) ) // cond: k > 0 && k < 7 && kbar == 8 - k // result: (Neq8 (And8 <t> n (Const8 <t> [1<<uint(k)-1])) (Const8 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { n := v_0 if v_1.Op != OpLsh8x64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpRsh8x64 { continue } _ = v_1_0.Args[1] v_1_0_0 := v_1_0.Args[0] if v_1_0_0.Op != OpAdd8 { continue } t := v_1_0_0.Type _ = v_1_0_0.Args[1] v_1_0_0_0 := v_1_0_0.Args[0] v_1_0_0_1 := v_1_0_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0_0_0, v_1_0_0_1 = _i1+1, v_1_0_0_1, v_1_0_0_0 { if n != v_1_0_0_0 || v_1_0_0_1.Op != OpRsh8Ux64 || v_1_0_0_1.Type != t { continue } _ = v_1_0_0_1.Args[1] v_1_0_0_1_0 := v_1_0_0_1.Args[0] if v_1_0_0_1_0.Op != OpRsh8x64 || v_1_0_0_1_0.Type != t { continue } _ = v_1_0_0_1_0.Args[1] if n != v_1_0_0_1_0.Args[0] { continue } v_1_0_0_1_0_1 := v_1_0_0_1_0.Args[1] if v_1_0_0_1_0_1.Op != OpConst64 || v_1_0_0_1_0_1.Type != typ.UInt64 || auxIntToInt64(v_1_0_0_1_0_1.AuxInt) != 7 { continue } v_1_0_0_1_1 := v_1_0_0_1.Args[1] if v_1_0_0_1_1.Op != OpConst64 || v_1_0_0_1_1.Type != typ.UInt64 { continue } kbar := auxIntToInt64(v_1_0_0_1_1.AuxInt) v_1_0_1 := v_1_0.Args[1] if v_1_0_1.Op != OpConst64 || v_1_0_1.Type != typ.UInt64 { continue } k := auxIntToInt64(v_1_0_1.AuxInt) v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != typ.UInt64 || auxIntToInt64(v_1_1.AuxInt) != k || !(k > 0 && k < 7 && kbar == 8-k) { continue } v.reset(OpNeq8) v0 := b.NewValue0(v.Pos, OpAnd8, t) v1 := b.NewValue0(v.Pos, OpConst8, t) v1.AuxInt = int8ToAuxInt(1<<uint(k) - 1) v0.AddArg2(n, v1) v2 := b.NewValue0(v.Pos, OpConst8, t) v2.AuxInt = int8ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } // match: (Neq8 s:(Sub8 x y) (Const8 [0])) // cond: s.Uses == 1 // result: (Neq8 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { s := v_0 if s.Op != OpSub8 { continue } y := s.Args[1] x := s.Args[0] if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != 0 || !(s.Uses == 1) { continue } v.reset(OpNeq8) v.AddArg2(x, y) return true } break } // match: (Neq8 (And8 <t> x (Const8 <t> [y])) (Const8 <t> [y])) // cond: oneBit8(y) // result: (Eq8 (And8 <t> x (Const8 <t> [y])) (Const8 <t> [0])) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd8 { continue } t := v_0.Type _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst8 || v_0_1.Type != t { continue } y := auxIntToInt8(v_0_1.AuxInt) if v_1.Op != OpConst8 || v_1.Type != t || auxIntToInt8(v_1.AuxInt) != y || !(oneBit8(y)) { continue } v.reset(OpEq8) v0 := b.NewValue0(v.Pos, OpAnd8, t) v1 := b.NewValue0(v.Pos, OpConst8, t) v1.AuxInt = int8ToAuxInt(y) v0.AddArg2(x, v1) v2 := b.NewValue0(v.Pos, OpConst8, t) v2.AuxInt = int8ToAuxInt(0) v.AddArg2(v0, v2) return true } } break } return false } func rewriteValuegeneric_OpNeqB(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (NeqB (ConstBool [c]) (ConstBool [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConstBool { continue } c := auxIntToBool(v_0.AuxInt) if v_1.Op != OpConstBool { continue } d := auxIntToBool(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } // match: (NeqB (ConstBool [false]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != false { continue } x := v_1 v.copyOf(x) return true } break } // match: (NeqB (ConstBool [true]) x) // result: (Not x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConstBool || auxIntToBool(v_0.AuxInt) != true { continue } x := v_1 v.reset(OpNot) v.AddArg(x) return true } break } // match: (NeqB (Not x) (Not y)) // result: (NeqB x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpNot { continue } x := v_0.Args[0] if v_1.Op != OpNot { continue } y := v_1.Args[0] v.reset(OpNeqB) v.AddArg2(x, y) return true } break } return false } func rewriteValuegeneric_OpNeqInter(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (NeqInter x y) // result: (NeqPtr (ITab x) (ITab y)) for { x := v_0 y := v_1 v.reset(OpNeqPtr) v0 := b.NewValue0(v.Pos, OpITab, typ.Uintptr) v0.AddArg(x) v1 := b.NewValue0(v.Pos, OpITab, typ.Uintptr) v1.AddArg(y) v.AddArg2(v0, v1) return true } } func rewriteValuegeneric_OpNeqPtr(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (NeqPtr x x) // result: (ConstBool [false]) for { x := v_0 if x != v_1 { break } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(false) return true } // match: (NeqPtr (Addr {a} _) (Addr {b} _)) // result: (ConstBool [a != b]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAddr { continue } a := auxToSym(v_0.Aux) if v_1.Op != OpAddr { continue } b := auxToSym(v_1.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a != b) return true } break } // match: (NeqPtr (Addr {a} _) (OffPtr [o] (Addr {b} _))) // result: (ConstBool [a != b || o != 0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAddr { continue } a := auxToSym(v_0.Aux) if v_1.Op != OpOffPtr { continue } o := auxIntToInt64(v_1.AuxInt) v_1_0 := v_1.Args[0] if v_1_0.Op != OpAddr { continue } b := auxToSym(v_1_0.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a != b || o != 0) return true } break } // match: (NeqPtr (OffPtr [o1] (Addr {a} _)) (OffPtr [o2] (Addr {b} _))) // result: (ConstBool [a != b || o1 != o2]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } o1 := auxIntToInt64(v_0.AuxInt) v_0_0 := v_0.Args[0] if v_0_0.Op != OpAddr { continue } a := auxToSym(v_0_0.Aux) if v_1.Op != OpOffPtr { continue } o2 := auxIntToInt64(v_1.AuxInt) v_1_0 := v_1.Args[0] if v_1_0.Op != OpAddr { continue } b := auxToSym(v_1_0.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a != b || o1 != o2) return true } break } // match: (NeqPtr (LocalAddr {a} _ _) (LocalAddr {b} _ _)) // result: (ConstBool [a != b]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLocalAddr { continue } a := auxToSym(v_0.Aux) if v_1.Op != OpLocalAddr { continue } b := auxToSym(v_1.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a != b) return true } break } // match: (NeqPtr (LocalAddr {a} _ _) (OffPtr [o] (LocalAddr {b} _ _))) // result: (ConstBool [a != b || o != 0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLocalAddr { continue } a := auxToSym(v_0.Aux) if v_1.Op != OpOffPtr { continue } o := auxIntToInt64(v_1.AuxInt) v_1_0 := v_1.Args[0] if v_1_0.Op != OpLocalAddr { continue } b := auxToSym(v_1_0.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a != b || o != 0) return true } break } // match: (NeqPtr (OffPtr [o1] (LocalAddr {a} _ _)) (OffPtr [o2] (LocalAddr {b} _ _))) // result: (ConstBool [a != b || o1 != o2]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } o1 := auxIntToInt64(v_0.AuxInt) v_0_0 := v_0.Args[0] if v_0_0.Op != OpLocalAddr { continue } a := auxToSym(v_0_0.Aux) if v_1.Op != OpOffPtr { continue } o2 := auxIntToInt64(v_1.AuxInt) v_1_0 := v_1.Args[0] if v_1_0.Op != OpLocalAddr { continue } b := auxToSym(v_1_0.Aux) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(a != b || o1 != o2) return true } break } // match: (NeqPtr (OffPtr [o1] p1) p2) // cond: isSamePtr(p1, p2) // result: (ConstBool [o1 != 0]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } o1 := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] p2 := v_1 if !(isSamePtr(p1, p2)) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(o1 != 0) return true } break } // match: (NeqPtr (OffPtr [o1] p1) (OffPtr [o2] p2)) // cond: isSamePtr(p1, p2) // result: (ConstBool [o1 != o2]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } o1 := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] if v_1.Op != OpOffPtr { continue } o2 := auxIntToInt64(v_1.AuxInt) p2 := v_1.Args[0] if !(isSamePtr(p1, p2)) { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(o1 != o2) return true } break } // match: (NeqPtr (Const32 [c]) (Const32 [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } // match: (NeqPtr (Const64 [c]) (Const64 [d])) // result: (ConstBool [c != d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(c != d) return true } break } // match: (NeqPtr (LocalAddr _ _) (Addr _)) // result: (ConstBool [true]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLocalAddr || v_1.Op != OpAddr { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (NeqPtr (OffPtr (LocalAddr _ _)) (Addr _)) // result: (ConstBool [true]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } v_0_0 := v_0.Args[0] if v_0_0.Op != OpLocalAddr || v_1.Op != OpAddr { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (NeqPtr (LocalAddr _ _) (OffPtr (Addr _))) // result: (ConstBool [true]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLocalAddr || v_1.Op != OpOffPtr { continue } v_1_0 := v_1.Args[0] if v_1_0.Op != OpAddr { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (NeqPtr (OffPtr (LocalAddr _ _)) (OffPtr (Addr _))) // result: (ConstBool [true]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOffPtr { continue } v_0_0 := v_0.Args[0] if v_0_0.Op != OpLocalAddr || v_1.Op != OpOffPtr { continue } v_1_0 := v_1.Args[0] if v_1_0.Op != OpAddr { continue } v.reset(OpConstBool) v.AuxInt = boolToAuxInt(true) return true } break } // match: (NeqPtr (AddPtr p1 o1) p2) // cond: isSamePtr(p1, p2) // result: (IsNonNil o1) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAddPtr { continue } o1 := v_0.Args[1] p1 := v_0.Args[0] p2 := v_1 if !(isSamePtr(p1, p2)) { continue } v.reset(OpIsNonNil) v.AddArg(o1) return true } break } // match: (NeqPtr (Const32 [0]) p) // result: (IsNonNil p) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { continue } p := v_1 v.reset(OpIsNonNil) v.AddArg(p) return true } break } // match: (NeqPtr (Const64 [0]) p) // result: (IsNonNil p) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { continue } p := v_1 v.reset(OpIsNonNil) v.AddArg(p) return true } break } // match: (NeqPtr (ConstNil) p) // result: (IsNonNil p) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConstNil { continue } p := v_1 v.reset(OpIsNonNil) v.AddArg(p) return true } break } return false } func rewriteValuegeneric_OpNeqSlice(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (NeqSlice x y) // result: (NeqPtr (SlicePtr x) (SlicePtr y)) for { x := v_0 y := v_1 v.reset(OpNeqPtr) v0 := b.NewValue0(v.Pos, OpSlicePtr, typ.BytePtr) v0.AddArg(x) v1 := b.NewValue0(v.Pos, OpSlicePtr, typ.BytePtr) v1.AddArg(y) v.AddArg2(v0, v1) return true } } func rewriteValuegeneric_OpNilCheck(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config fe := b.Func.fe // match: (NilCheck (GetG mem) mem) // result: mem for { if v_0.Op != OpGetG { break } mem := v_0.Args[0] if mem != v_1 { break } v.copyOf(mem) return true } // match: (NilCheck (Load (OffPtr [c] (SP)) (StaticCall {sym} _)) _) // cond: symNamed(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check") // result: (Invalid) for { if v_0.Op != OpLoad { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpOffPtr { break } c := auxIntToInt64(v_0_0.AuxInt) v_0_0_0 := v_0_0.Args[0] if v_0_0_0.Op != OpSP { break } v_0_1 := v_0.Args[1] if v_0_1.Op != OpStaticCall { break } sym := auxToSym(v_0_1.Aux) if !(symNamed(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")) { break } v.reset(OpInvalid) return true } // match: (NilCheck (OffPtr (Load (OffPtr [c] (SP)) (StaticCall {sym} _))) _) // cond: symNamed(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check") // result: (Invalid) for { if v_0.Op != OpOffPtr { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpLoad { break } _ = v_0_0.Args[1] v_0_0_0 := v_0_0.Args[0] if v_0_0_0.Op != OpOffPtr { break } c := auxIntToInt64(v_0_0_0.AuxInt) v_0_0_0_0 := v_0_0_0.Args[0] if v_0_0_0_0.Op != OpSP { break } v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpStaticCall { break } sym := auxToSym(v_0_0_1.Aux) if !(symNamed(sym, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize && warnRule(fe.Debug_checknil(), v, "removed nil check")) { break } v.reset(OpInvalid) return true } return false } func rewriteValuegeneric_OpNot(v *Value) bool { v_0 := v.Args[0] // match: (Not (ConstBool [c])) // result: (ConstBool [!c]) for { if v_0.Op != OpConstBool { break } c := auxIntToBool(v_0.AuxInt) v.reset(OpConstBool) v.AuxInt = boolToAuxInt(!c) return true } // match: (Not (Eq64 x y)) // result: (Neq64 x y) for { if v_0.Op != OpEq64 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpNeq64) v.AddArg2(x, y) return true } // match: (Not (Eq32 x y)) // result: (Neq32 x y) for { if v_0.Op != OpEq32 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpNeq32) v.AddArg2(x, y) return true } // match: (Not (Eq16 x y)) // result: (Neq16 x y) for { if v_0.Op != OpEq16 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpNeq16) v.AddArg2(x, y) return true } // match: (Not (Eq8 x y)) // result: (Neq8 x y) for { if v_0.Op != OpEq8 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpNeq8) v.AddArg2(x, y) return true } // match: (Not (EqB x y)) // result: (NeqB x y) for { if v_0.Op != OpEqB { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpNeqB) v.AddArg2(x, y) return true } // match: (Not (EqPtr x y)) // result: (NeqPtr x y) for { if v_0.Op != OpEqPtr { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpNeqPtr) v.AddArg2(x, y) return true } // match: (Not (Eq64F x y)) // result: (Neq64F x y) for { if v_0.Op != OpEq64F { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpNeq64F) v.AddArg2(x, y) return true } // match: (Not (Eq32F x y)) // result: (Neq32F x y) for { if v_0.Op != OpEq32F { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpNeq32F) v.AddArg2(x, y) return true } // match: (Not (Neq64 x y)) // result: (Eq64 x y) for { if v_0.Op != OpNeq64 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpEq64) v.AddArg2(x, y) return true } // match: (Not (Neq32 x y)) // result: (Eq32 x y) for { if v_0.Op != OpNeq32 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpEq32) v.AddArg2(x, y) return true } // match: (Not (Neq16 x y)) // result: (Eq16 x y) for { if v_0.Op != OpNeq16 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpEq16) v.AddArg2(x, y) return true } // match: (Not (Neq8 x y)) // result: (Eq8 x y) for { if v_0.Op != OpNeq8 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpEq8) v.AddArg2(x, y) return true } // match: (Not (NeqB x y)) // result: (EqB x y) for { if v_0.Op != OpNeqB { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpEqB) v.AddArg2(x, y) return true } // match: (Not (NeqPtr x y)) // result: (EqPtr x y) for { if v_0.Op != OpNeqPtr { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpEqPtr) v.AddArg2(x, y) return true } // match: (Not (Neq64F x y)) // result: (Eq64F x y) for { if v_0.Op != OpNeq64F { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpEq64F) v.AddArg2(x, y) return true } // match: (Not (Neq32F x y)) // result: (Eq32F x y) for { if v_0.Op != OpNeq32F { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpEq32F) v.AddArg2(x, y) return true } // match: (Not (Less64 x y)) // result: (Leq64 y x) for { if v_0.Op != OpLess64 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLeq64) v.AddArg2(y, x) return true } // match: (Not (Less32 x y)) // result: (Leq32 y x) for { if v_0.Op != OpLess32 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLeq32) v.AddArg2(y, x) return true } // match: (Not (Less16 x y)) // result: (Leq16 y x) for { if v_0.Op != OpLess16 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLeq16) v.AddArg2(y, x) return true } // match: (Not (Less8 x y)) // result: (Leq8 y x) for { if v_0.Op != OpLess8 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLeq8) v.AddArg2(y, x) return true } // match: (Not (Less64U x y)) // result: (Leq64U y x) for { if v_0.Op != OpLess64U { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLeq64U) v.AddArg2(y, x) return true } // match: (Not (Less32U x y)) // result: (Leq32U y x) for { if v_0.Op != OpLess32U { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLeq32U) v.AddArg2(y, x) return true } // match: (Not (Less16U x y)) // result: (Leq16U y x) for { if v_0.Op != OpLess16U { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLeq16U) v.AddArg2(y, x) return true } // match: (Not (Less8U x y)) // result: (Leq8U y x) for { if v_0.Op != OpLess8U { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLeq8U) v.AddArg2(y, x) return true } // match: (Not (Leq64 x y)) // result: (Less64 y x) for { if v_0.Op != OpLeq64 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLess64) v.AddArg2(y, x) return true } // match: (Not (Leq32 x y)) // result: (Less32 y x) for { if v_0.Op != OpLeq32 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLess32) v.AddArg2(y, x) return true } // match: (Not (Leq16 x y)) // result: (Less16 y x) for { if v_0.Op != OpLeq16 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLess16) v.AddArg2(y, x) return true } // match: (Not (Leq8 x y)) // result: (Less8 y x) for { if v_0.Op != OpLeq8 { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLess8) v.AddArg2(y, x) return true } // match: (Not (Leq64U x y)) // result: (Less64U y x) for { if v_0.Op != OpLeq64U { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLess64U) v.AddArg2(y, x) return true } // match: (Not (Leq32U x y)) // result: (Less32U y x) for { if v_0.Op != OpLeq32U { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLess32U) v.AddArg2(y, x) return true } // match: (Not (Leq16U x y)) // result: (Less16U y x) for { if v_0.Op != OpLeq16U { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLess16U) v.AddArg2(y, x) return true } // match: (Not (Leq8U x y)) // result: (Less8U y x) for { if v_0.Op != OpLeq8U { break } y := v_0.Args[1] x := v_0.Args[0] v.reset(OpLess8U) v.AddArg2(y, x) return true } return false } func rewriteValuegeneric_OpOffPtr(v *Value) bool { v_0 := v.Args[0] // match: (OffPtr (OffPtr p [b]) [a]) // result: (OffPtr p [a+b]) for { a := auxIntToInt64(v.AuxInt) if v_0.Op != OpOffPtr { break } b := auxIntToInt64(v_0.AuxInt) p := v_0.Args[0] v.reset(OpOffPtr) v.AuxInt = int64ToAuxInt(a + b) v.AddArg(p) return true } // match: (OffPtr p [0]) // cond: v.Type.Compare(p.Type) == types.CMPeq // result: p for { if auxIntToInt64(v.AuxInt) != 0 { break } p := v_0 if !(v.Type.Compare(p.Type) == types.CMPeq) { break } v.copyOf(p) return true } return false } func rewriteValuegeneric_OpOr16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Or16 (Const16 [c]) (Const16 [d])) // result: (Const16 [c|d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c | d) return true } break } // match: (Or16 x x) // result: x for { x := v_0 if x != v_1 { break } v.copyOf(x) return true } // match: (Or16 (Const16 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Or16 (Const16 [-1]) _) // result: (Const16 [-1]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != -1 { continue } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(-1) return true } break } // match: (Or16 x (Or16 x y)) // result: (Or16 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpOr16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.reset(OpOr16) v.AddArg2(x, y) return true } } break } // match: (Or16 (And16 x (Const16 [c2])) (Const16 <t> [c1])) // cond: ^(c1 | c2) == 0 // result: (Or16 (Const16 <t> [c1]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd16 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst16 { continue } c2 := auxIntToInt16(v_0_1.AuxInt) if v_1.Op != OpConst16 { continue } t := v_1.Type c1 := auxIntToInt16(v_1.AuxInt) if !(^(c1 | c2) == 0) { continue } v.reset(OpOr16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c1) v.AddArg2(v0, x) return true } } break } // match: (Or16 (Or16 i:(Const16 <t>) z) x) // cond: (z.Op != OpConst16 && x.Op != OpConst16) // result: (Or16 i (Or16 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOr16 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst16 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst16 && x.Op != OpConst16) { continue } v.reset(OpOr16) v0 := b.NewValue0(v.Pos, OpOr16, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Or16 (Const16 <t> [c]) (Or16 (Const16 <t> [d]) x)) // result: (Or16 (Const16 <t> [c|d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpOr16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 || v_1_0.Type != t { continue } d := auxIntToInt16(v_1_0.AuxInt) x := v_1_1 v.reset(OpOr16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c | d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpOr32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Or32 (Const32 [c]) (Const32 [d])) // result: (Const32 [c|d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c | d) return true } break } // match: (Or32 x x) // result: x for { x := v_0 if x != v_1 { break } v.copyOf(x) return true } // match: (Or32 (Const32 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Or32 (Const32 [-1]) _) // result: (Const32 [-1]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != -1 { continue } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(-1) return true } break } // match: (Or32 x (Or32 x y)) // result: (Or32 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpOr32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.reset(OpOr32) v.AddArg2(x, y) return true } } break } // match: (Or32 (And32 x (Const32 [c2])) (Const32 <t> [c1])) // cond: ^(c1 | c2) == 0 // result: (Or32 (Const32 <t> [c1]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd32 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst32 { continue } c2 := auxIntToInt32(v_0_1.AuxInt) if v_1.Op != OpConst32 { continue } t := v_1.Type c1 := auxIntToInt32(v_1.AuxInt) if !(^(c1 | c2) == 0) { continue } v.reset(OpOr32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c1) v.AddArg2(v0, x) return true } } break } // match: (Or32 (Or32 i:(Const32 <t>) z) x) // cond: (z.Op != OpConst32 && x.Op != OpConst32) // result: (Or32 i (Or32 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOr32 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst32 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst32 && x.Op != OpConst32) { continue } v.reset(OpOr32) v0 := b.NewValue0(v.Pos, OpOr32, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Or32 (Const32 <t> [c]) (Or32 (Const32 <t> [d]) x)) // result: (Or32 (Const32 <t> [c|d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpOr32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) x := v_1_1 v.reset(OpOr32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c | d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpOr64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Or64 (Const64 [c]) (Const64 [d])) // result: (Const64 [c|d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c | d) return true } break } // match: (Or64 x x) // result: x for { x := v_0 if x != v_1 { break } v.copyOf(x) return true } // match: (Or64 (Const64 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Or64 (Const64 [-1]) _) // result: (Const64 [-1]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != -1 { continue } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(-1) return true } break } // match: (Or64 x (Or64 x y)) // result: (Or64 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpOr64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.reset(OpOr64) v.AddArg2(x, y) return true } } break } // match: (Or64 (And64 x (Const64 [c2])) (Const64 <t> [c1])) // cond: ^(c1 | c2) == 0 // result: (Or64 (Const64 <t> [c1]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd64 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst64 { continue } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { continue } t := v_1.Type c1 := auxIntToInt64(v_1.AuxInt) if !(^(c1 | c2) == 0) { continue } v.reset(OpOr64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c1) v.AddArg2(v0, x) return true } } break } // match: (Or64 (Or64 i:(Const64 <t>) z) x) // cond: (z.Op != OpConst64 && x.Op != OpConst64) // result: (Or64 i (Or64 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOr64 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst64 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst64 && x.Op != OpConst64) { continue } v.reset(OpOr64) v0 := b.NewValue0(v.Pos, OpOr64, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Or64 (Const64 <t> [c]) (Or64 (Const64 <t> [d]) x)) // result: (Or64 (Const64 <t> [c|d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpOr64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 v.reset(OpOr64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c | d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpOr8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Or8 (Const8 [c]) (Const8 [d])) // result: (Const8 [c|d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c | d) return true } break } // match: (Or8 x x) // result: x for { x := v_0 if x != v_1 { break } v.copyOf(x) return true } // match: (Or8 (Const8 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Or8 (Const8 [-1]) _) // result: (Const8 [-1]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != -1 { continue } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(-1) return true } break } // match: (Or8 x (Or8 x y)) // result: (Or8 x y) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpOr8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.reset(OpOr8) v.AddArg2(x, y) return true } } break } // match: (Or8 (And8 x (Const8 [c2])) (Const8 <t> [c1])) // cond: ^(c1 | c2) == 0 // result: (Or8 (Const8 <t> [c1]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpAnd8 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { x := v_0_0 if v_0_1.Op != OpConst8 { continue } c2 := auxIntToInt8(v_0_1.AuxInt) if v_1.Op != OpConst8 { continue } t := v_1.Type c1 := auxIntToInt8(v_1.AuxInt) if !(^(c1 | c2) == 0) { continue } v.reset(OpOr8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c1) v.AddArg2(v0, x) return true } } break } // match: (Or8 (Or8 i:(Const8 <t>) z) x) // cond: (z.Op != OpConst8 && x.Op != OpConst8) // result: (Or8 i (Or8 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpOr8 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst8 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst8 && x.Op != OpConst8) { continue } v.reset(OpOr8) v0 := b.NewValue0(v.Pos, OpOr8, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Or8 (Const8 <t> [c]) (Or8 (Const8 <t> [d]) x)) // result: (Or8 (Const8 <t> [c|d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpOr8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 || v_1_0.Type != t { continue } d := auxIntToInt8(v_1_0.AuxInt) x := v_1_1 v.reset(OpOr8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c | d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpOrB(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (OrB (Less64 (Const64 [c]) x) (Less64 x (Const64 [d]))) // cond: c >= d // result: (Less64U (Const64 <x.Type> [c-d]) (Sub64 <x.Type> x (Const64 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess64 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLess64 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(c >= d) { continue } v.reset(OpLess64U) v0 := b.NewValue0(v.Pos, OpConst64, x.Type) v0.AuxInt = int64ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub64, x.Type) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq64 (Const64 [c]) x) (Less64 x (Const64 [d]))) // cond: c >= d // result: (Leq64U (Const64 <x.Type> [c-d]) (Sub64 <x.Type> x (Const64 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq64 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLess64 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(c >= d) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpConst64, x.Type) v0.AuxInt = int64ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub64, x.Type) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less32 (Const32 [c]) x) (Less32 x (Const32 [d]))) // cond: c >= d // result: (Less32U (Const32 <x.Type> [c-d]) (Sub32 <x.Type> x (Const32 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess32 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLess32 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(c >= d) { continue } v.reset(OpLess32U) v0 := b.NewValue0(v.Pos, OpConst32, x.Type) v0.AuxInt = int32ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub32, x.Type) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq32 (Const32 [c]) x) (Less32 x (Const32 [d]))) // cond: c >= d // result: (Leq32U (Const32 <x.Type> [c-d]) (Sub32 <x.Type> x (Const32 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq32 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLess32 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(c >= d) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpConst32, x.Type) v0.AuxInt = int32ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub32, x.Type) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less16 (Const16 [c]) x) (Less16 x (Const16 [d]))) // cond: c >= d // result: (Less16U (Const16 <x.Type> [c-d]) (Sub16 <x.Type> x (Const16 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess16 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLess16 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(c >= d) { continue } v.reset(OpLess16U) v0 := b.NewValue0(v.Pos, OpConst16, x.Type) v0.AuxInt = int16ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub16, x.Type) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq16 (Const16 [c]) x) (Less16 x (Const16 [d]))) // cond: c >= d // result: (Leq16U (Const16 <x.Type> [c-d]) (Sub16 <x.Type> x (Const16 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq16 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLess16 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(c >= d) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpConst16, x.Type) v0.AuxInt = int16ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub16, x.Type) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less8 (Const8 [c]) x) (Less8 x (Const8 [d]))) // cond: c >= d // result: (Less8U (Const8 <x.Type> [c-d]) (Sub8 <x.Type> x (Const8 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess8 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLess8 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(c >= d) { continue } v.reset(OpLess8U) v0 := b.NewValue0(v.Pos, OpConst8, x.Type) v0.AuxInt = int8ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub8, x.Type) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq8 (Const8 [c]) x) (Less8 x (Const8 [d]))) // cond: c >= d // result: (Leq8U (Const8 <x.Type> [c-d]) (Sub8 <x.Type> x (Const8 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq8 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLess8 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(c >= d) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpConst8, x.Type) v0.AuxInt = int8ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub8, x.Type) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less64 (Const64 [c]) x) (Leq64 x (Const64 [d]))) // cond: c >= d+1 && d+1 > d // result: (Less64U (Const64 <x.Type> [c-d-1]) (Sub64 <x.Type> x (Const64 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess64 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLeq64 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(c >= d+1 && d+1 > d) { continue } v.reset(OpLess64U) v0 := b.NewValue0(v.Pos, OpConst64, x.Type) v0.AuxInt = int64ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub64, x.Type) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq64 (Const64 [c]) x) (Leq64 x (Const64 [d]))) // cond: c >= d+1 && d+1 > d // result: (Leq64U (Const64 <x.Type> [c-d-1]) (Sub64 <x.Type> x (Const64 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq64 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLeq64 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(c >= d+1 && d+1 > d) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpConst64, x.Type) v0.AuxInt = int64ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub64, x.Type) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less32 (Const32 [c]) x) (Leq32 x (Const32 [d]))) // cond: c >= d+1 && d+1 > d // result: (Less32U (Const32 <x.Type> [c-d-1]) (Sub32 <x.Type> x (Const32 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess32 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLeq32 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(c >= d+1 && d+1 > d) { continue } v.reset(OpLess32U) v0 := b.NewValue0(v.Pos, OpConst32, x.Type) v0.AuxInt = int32ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub32, x.Type) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq32 (Const32 [c]) x) (Leq32 x (Const32 [d]))) // cond: c >= d+1 && d+1 > d // result: (Leq32U (Const32 <x.Type> [c-d-1]) (Sub32 <x.Type> x (Const32 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq32 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLeq32 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(c >= d+1 && d+1 > d) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpConst32, x.Type) v0.AuxInt = int32ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub32, x.Type) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less16 (Const16 [c]) x) (Leq16 x (Const16 [d]))) // cond: c >= d+1 && d+1 > d // result: (Less16U (Const16 <x.Type> [c-d-1]) (Sub16 <x.Type> x (Const16 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess16 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLeq16 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(c >= d+1 && d+1 > d) { continue } v.reset(OpLess16U) v0 := b.NewValue0(v.Pos, OpConst16, x.Type) v0.AuxInt = int16ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub16, x.Type) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq16 (Const16 [c]) x) (Leq16 x (Const16 [d]))) // cond: c >= d+1 && d+1 > d // result: (Leq16U (Const16 <x.Type> [c-d-1]) (Sub16 <x.Type> x (Const16 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq16 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLeq16 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(c >= d+1 && d+1 > d) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpConst16, x.Type) v0.AuxInt = int16ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub16, x.Type) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less8 (Const8 [c]) x) (Leq8 x (Const8 [d]))) // cond: c >= d+1 && d+1 > d // result: (Less8U (Const8 <x.Type> [c-d-1]) (Sub8 <x.Type> x (Const8 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess8 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLeq8 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(c >= d+1 && d+1 > d) { continue } v.reset(OpLess8U) v0 := b.NewValue0(v.Pos, OpConst8, x.Type) v0.AuxInt = int8ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub8, x.Type) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq8 (Const8 [c]) x) (Leq8 x (Const8 [d]))) // cond: c >= d+1 && d+1 > d // result: (Leq8U (Const8 <x.Type> [c-d-1]) (Sub8 <x.Type> x (Const8 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq8 { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLeq8 { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(c >= d+1 && d+1 > d) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpConst8, x.Type) v0.AuxInt = int8ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub8, x.Type) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less64U (Const64 [c]) x) (Less64U x (Const64 [d]))) // cond: uint64(c) >= uint64(d) // result: (Less64U (Const64 <x.Type> [c-d]) (Sub64 <x.Type> x (Const64 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess64U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLess64U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(uint64(c) >= uint64(d)) { continue } v.reset(OpLess64U) v0 := b.NewValue0(v.Pos, OpConst64, x.Type) v0.AuxInt = int64ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub64, x.Type) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq64U (Const64 [c]) x) (Less64U x (Const64 [d]))) // cond: uint64(c) >= uint64(d) // result: (Leq64U (Const64 <x.Type> [c-d]) (Sub64 <x.Type> x (Const64 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq64U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLess64U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(uint64(c) >= uint64(d)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpConst64, x.Type) v0.AuxInt = int64ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub64, x.Type) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less32U (Const32 [c]) x) (Less32U x (Const32 [d]))) // cond: uint32(c) >= uint32(d) // result: (Less32U (Const32 <x.Type> [c-d]) (Sub32 <x.Type> x (Const32 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess32U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLess32U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(uint32(c) >= uint32(d)) { continue } v.reset(OpLess32U) v0 := b.NewValue0(v.Pos, OpConst32, x.Type) v0.AuxInt = int32ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub32, x.Type) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq32U (Const32 [c]) x) (Less32U x (Const32 [d]))) // cond: uint32(c) >= uint32(d) // result: (Leq32U (Const32 <x.Type> [c-d]) (Sub32 <x.Type> x (Const32 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq32U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLess32U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(uint32(c) >= uint32(d)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpConst32, x.Type) v0.AuxInt = int32ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub32, x.Type) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less16U (Const16 [c]) x) (Less16U x (Const16 [d]))) // cond: uint16(c) >= uint16(d) // result: (Less16U (Const16 <x.Type> [c-d]) (Sub16 <x.Type> x (Const16 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess16U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLess16U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(uint16(c) >= uint16(d)) { continue } v.reset(OpLess16U) v0 := b.NewValue0(v.Pos, OpConst16, x.Type) v0.AuxInt = int16ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub16, x.Type) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq16U (Const16 [c]) x) (Less16U x (Const16 [d]))) // cond: uint16(c) >= uint16(d) // result: (Leq16U (Const16 <x.Type> [c-d]) (Sub16 <x.Type> x (Const16 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq16U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLess16U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(uint16(c) >= uint16(d)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpConst16, x.Type) v0.AuxInt = int16ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub16, x.Type) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less8U (Const8 [c]) x) (Less8U x (Const8 [d]))) // cond: uint8(c) >= uint8(d) // result: (Less8U (Const8 <x.Type> [c-d]) (Sub8 <x.Type> x (Const8 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess8U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLess8U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(uint8(c) >= uint8(d)) { continue } v.reset(OpLess8U) v0 := b.NewValue0(v.Pos, OpConst8, x.Type) v0.AuxInt = int8ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub8, x.Type) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq8U (Const8 [c]) x) (Less8U x (Const8 [d]))) // cond: uint8(c) >= uint8(d) // result: (Leq8U (Const8 <x.Type> [c-d]) (Sub8 <x.Type> x (Const8 <x.Type> [d]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq8U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLess8U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(uint8(c) >= uint8(d)) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpConst8, x.Type) v0.AuxInt = int8ToAuxInt(c - d) v1 := b.NewValue0(v.Pos, OpSub8, x.Type) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less64U (Const64 [c]) x) (Leq64U x (Const64 [d]))) // cond: uint64(c) >= uint64(d+1) && uint64(d+1) > uint64(d) // result: (Less64U (Const64 <x.Type> [c-d-1]) (Sub64 <x.Type> x (Const64 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess64U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLeq64U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(uint64(c) >= uint64(d+1) && uint64(d+1) > uint64(d)) { continue } v.reset(OpLess64U) v0 := b.NewValue0(v.Pos, OpConst64, x.Type) v0.AuxInt = int64ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub64, x.Type) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq64U (Const64 [c]) x) (Leq64U x (Const64 [d]))) // cond: uint64(c) >= uint64(d+1) && uint64(d+1) > uint64(d) // result: (Leq64U (Const64 <x.Type> [c-d-1]) (Sub64 <x.Type> x (Const64 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq64U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0_0.AuxInt) if v_1.Op != OpLeq64U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1_1.AuxInt) if !(uint64(c) >= uint64(d+1) && uint64(d+1) > uint64(d)) { continue } v.reset(OpLeq64U) v0 := b.NewValue0(v.Pos, OpConst64, x.Type) v0.AuxInt = int64ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub64, x.Type) v2 := b.NewValue0(v.Pos, OpConst64, x.Type) v2.AuxInt = int64ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less32U (Const32 [c]) x) (Leq32U x (Const32 [d]))) // cond: uint32(c) >= uint32(d+1) && uint32(d+1) > uint32(d) // result: (Less32U (Const32 <x.Type> [c-d-1]) (Sub32 <x.Type> x (Const32 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess32U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLeq32U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(uint32(c) >= uint32(d+1) && uint32(d+1) > uint32(d)) { continue } v.reset(OpLess32U) v0 := b.NewValue0(v.Pos, OpConst32, x.Type) v0.AuxInt = int32ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub32, x.Type) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq32U (Const32 [c]) x) (Leq32U x (Const32 [d]))) // cond: uint32(c) >= uint32(d+1) && uint32(d+1) > uint32(d) // result: (Leq32U (Const32 <x.Type> [c-d-1]) (Sub32 <x.Type> x (Const32 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq32U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0_0.AuxInt) if v_1.Op != OpLeq32U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1_1.AuxInt) if !(uint32(c) >= uint32(d+1) && uint32(d+1) > uint32(d)) { continue } v.reset(OpLeq32U) v0 := b.NewValue0(v.Pos, OpConst32, x.Type) v0.AuxInt = int32ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub32, x.Type) v2 := b.NewValue0(v.Pos, OpConst32, x.Type) v2.AuxInt = int32ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less16U (Const16 [c]) x) (Leq16U x (Const16 [d]))) // cond: uint16(c) >= uint16(d+1) && uint16(d+1) > uint16(d) // result: (Less16U (Const16 <x.Type> [c-d-1]) (Sub16 <x.Type> x (Const16 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess16U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLeq16U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(uint16(c) >= uint16(d+1) && uint16(d+1) > uint16(d)) { continue } v.reset(OpLess16U) v0 := b.NewValue0(v.Pos, OpConst16, x.Type) v0.AuxInt = int16ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub16, x.Type) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq16U (Const16 [c]) x) (Leq16U x (Const16 [d]))) // cond: uint16(c) >= uint16(d+1) && uint16(d+1) > uint16(d) // result: (Leq16U (Const16 <x.Type> [c-d-1]) (Sub16 <x.Type> x (Const16 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq16U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0_0.AuxInt) if v_1.Op != OpLeq16U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1_1.AuxInt) if !(uint16(c) >= uint16(d+1) && uint16(d+1) > uint16(d)) { continue } v.reset(OpLeq16U) v0 := b.NewValue0(v.Pos, OpConst16, x.Type) v0.AuxInt = int16ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub16, x.Type) v2 := b.NewValue0(v.Pos, OpConst16, x.Type) v2.AuxInt = int16ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Less8U (Const8 [c]) x) (Leq8U x (Const8 [d]))) // cond: uint8(c) >= uint8(d+1) && uint8(d+1) > uint8(d) // result: (Less8U (Const8 <x.Type> [c-d-1]) (Sub8 <x.Type> x (Const8 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLess8U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLeq8U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(uint8(c) >= uint8(d+1) && uint8(d+1) > uint8(d)) { continue } v.reset(OpLess8U) v0 := b.NewValue0(v.Pos, OpConst8, x.Type) v0.AuxInt = int8ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub8, x.Type) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } // match: (OrB (Leq8U (Const8 [c]) x) (Leq8U x (Const8 [d]))) // cond: uint8(c) >= uint8(d+1) && uint8(d+1) > uint8(d) // result: (Leq8U (Const8 <x.Type> [c-d-1]) (Sub8 <x.Type> x (Const8 <x.Type> [d+1]))) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpLeq8U { continue } x := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0_0.AuxInt) if v_1.Op != OpLeq8U { continue } _ = v_1.Args[1] if x != v_1.Args[0] { continue } v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1_1.AuxInt) if !(uint8(c) >= uint8(d+1) && uint8(d+1) > uint8(d)) { continue } v.reset(OpLeq8U) v0 := b.NewValue0(v.Pos, OpConst8, x.Type) v0.AuxInt = int8ToAuxInt(c - d - 1) v1 := b.NewValue0(v.Pos, OpSub8, x.Type) v2 := b.NewValue0(v.Pos, OpConst8, x.Type) v2.AuxInt = int8ToAuxInt(d + 1) v1.AddArg2(x, v2) v.AddArg2(v0, v1) return true } break } return false } func rewriteValuegeneric_OpPhi(v *Value) bool { // match: (Phi (Const8 [c]) (Const8 [c])) // result: (Const8 [c]) for { _ = v.Args[1] v_0 := v.Args[0] if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v_1 := v.Args[1] if v_1.Op != OpConst8 || auxIntToInt8(v_1.AuxInt) != c || len(v.Args) != 2 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c) return true } // match: (Phi (Const16 [c]) (Const16 [c])) // result: (Const16 [c]) for { _ = v.Args[1] v_0 := v.Args[0] if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) v_1 := v.Args[1] if v_1.Op != OpConst16 || auxIntToInt16(v_1.AuxInt) != c || len(v.Args) != 2 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c) return true } // match: (Phi (Const32 [c]) (Const32 [c])) // result: (Const32 [c]) for { _ = v.Args[1] v_0 := v.Args[0] if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v_1 := v.Args[1] if v_1.Op != OpConst32 || auxIntToInt32(v_1.AuxInt) != c || len(v.Args) != 2 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c) return true } // match: (Phi (Const64 [c]) (Const64 [c])) // result: (Const64 [c]) for { _ = v.Args[1] v_0 := v.Args[0] if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v_1 := v.Args[1] if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != c || len(v.Args) != 2 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c) return true } return false } func rewriteValuegeneric_OpPtrIndex(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config typ := &b.Func.Config.Types // match: (PtrIndex <t> ptr idx) // cond: config.PtrSize == 4 && is32Bit(t.Elem().Size()) // result: (AddPtr ptr (Mul32 <typ.Int> idx (Const32 <typ.Int> [int32(t.Elem().Size())]))) for { t := v.Type ptr := v_0 idx := v_1 if !(config.PtrSize == 4 && is32Bit(t.Elem().Size())) { break } v.reset(OpAddPtr) v0 := b.NewValue0(v.Pos, OpMul32, typ.Int) v1 := b.NewValue0(v.Pos, OpConst32, typ.Int) v1.AuxInt = int32ToAuxInt(int32(t.Elem().Size())) v0.AddArg2(idx, v1) v.AddArg2(ptr, v0) return true } // match: (PtrIndex <t> ptr idx) // cond: config.PtrSize == 8 // result: (AddPtr ptr (Mul64 <typ.Int> idx (Const64 <typ.Int> [t.Elem().Size()]))) for { t := v.Type ptr := v_0 idx := v_1 if !(config.PtrSize == 8) { break } v.reset(OpAddPtr) v0 := b.NewValue0(v.Pos, OpMul64, typ.Int) v1 := b.NewValue0(v.Pos, OpConst64, typ.Int) v1.AuxInt = int64ToAuxInt(t.Elem().Size()) v0.AddArg2(idx, v1) v.AddArg2(ptr, v0) return true } return false } func rewriteValuegeneric_OpRotateLeft16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (RotateLeft16 x (Const16 [c])) // cond: c%16 == 0 // result: x for { x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) if !(c%16 == 0) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpRotateLeft32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (RotateLeft32 x (Const32 [c])) // cond: c%32 == 0 // result: x for { x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) if !(c%32 == 0) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpRotateLeft64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (RotateLeft64 x (Const64 [c])) // cond: c%64 == 0 // result: x for { x := v_0 if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(c%64 == 0) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpRotateLeft8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (RotateLeft8 x (Const8 [c])) // cond: c%8 == 0 // result: x for { x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) if !(c%8 == 0) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpRound32F(v *Value) bool { v_0 := v.Args[0] // match: (Round32F x:(Const32F)) // result: x for { x := v_0 if x.Op != OpConst32F { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpRound64F(v *Value) bool { v_0 := v.Args[0] // match: (Round64F x:(Const64F)) // result: x for { x := v_0 if x.Op != OpConst64F { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpRsh16Ux16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh16Ux16 <t> x (Const16 [c])) // result: (Rsh16Ux64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Rsh16Ux16 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh16Ux32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh16Ux32 <t> x (Const32 [c])) // result: (Rsh16Ux64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Rsh16Ux32 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh16Ux64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Rsh16Ux64 (Const16 [c]) (Const64 [d])) // result: (Const16 [int16(uint16(c) >> uint64(d))]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(int16(uint16(c) >> uint64(d))) return true } // match: (Rsh16Ux64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Rsh16Ux64 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } // match: (Rsh16Ux64 _ (Const64 [c])) // cond: uint64(c) >= 16 // result: (Const16 [0]) for { if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(uint64(c) >= 16) { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } // match: (Rsh16Ux64 <t> (Rsh16Ux64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Rsh16Ux64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpRsh16Ux64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Rsh16Ux64 (Rsh16x64 x _) (Const64 <t> [15])) // result: (Rsh16Ux64 x (Const64 <t> [15])) for { if v_0.Op != OpRsh16x64 { break } x := v_0.Args[0] if v_1.Op != OpConst64 { break } t := v_1.Type if auxIntToInt64(v_1.AuxInt) != 15 { break } v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(15) v.AddArg2(x, v0) return true } // match: (Rsh16Ux64 (Lsh16x64 (Rsh16Ux64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) // result: (Rsh16Ux64 x (Const64 <typ.UInt64> [c1-c2+c3])) for { if v_0.Op != OpLsh16x64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh16Ux64 { break } _ = v_0_0.Args[1] x := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c1 := auxIntToInt64(v_0_0_1.AuxInt) v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } c3 := auxIntToInt64(v_1.AuxInt) if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { break } v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) v.AddArg2(x, v0) return true } // match: (Rsh16Ux64 (Lsh16x64 x (Const64 [8])) (Const64 [8])) // result: (ZeroExt8to16 (Trunc16to8 <typ.UInt8> x)) for { if v_0.Op != OpLsh16x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 8 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 8 { break } v.reset(OpZeroExt8to16) v0 := b.NewValue0(v.Pos, OpTrunc16to8, typ.UInt8) v0.AddArg(x) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpRsh16Ux8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh16Ux8 <t> x (Const8 [c])) // result: (Rsh16Ux64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpRsh16Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Rsh16Ux8 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh16x16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh16x16 <t> x (Const16 [c])) // result: (Rsh16x64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpRsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Rsh16x16 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh16x32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh16x32 <t> x (Const32 [c])) // result: (Rsh16x64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpRsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Rsh16x32 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh16x64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Rsh16x64 (Const16 [c]) (Const64 [d])) // result: (Const16 [c >> uint64(d)]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c >> uint64(d)) return true } // match: (Rsh16x64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Rsh16x64 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } // match: (Rsh16x64 <t> (Rsh16x64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Rsh16x64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpRsh16x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpRsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Rsh16x64 (Lsh16x64 x (Const64 [8])) (Const64 [8])) // result: (SignExt8to16 (Trunc16to8 <typ.Int8> x)) for { if v_0.Op != OpLsh16x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 8 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 8 { break } v.reset(OpSignExt8to16) v0 := b.NewValue0(v.Pos, OpTrunc16to8, typ.Int8) v0.AddArg(x) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpRsh16x8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh16x8 <t> x (Const8 [c])) // result: (Rsh16x64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpRsh16x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Rsh16x8 (Const16 [0]) _) // result: (Const16 [0]) for { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh32Ux16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh32Ux16 <t> x (Const16 [c])) // result: (Rsh32Ux64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Rsh32Ux16 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh32Ux32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh32Ux32 <t> x (Const32 [c])) // result: (Rsh32Ux64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Rsh32Ux32 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh32Ux64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Rsh32Ux64 (Const32 [c]) (Const64 [d])) // result: (Const32 [int32(uint32(c) >> uint64(d))]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(uint32(c) >> uint64(d))) return true } // match: (Rsh32Ux64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Rsh32Ux64 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Rsh32Ux64 _ (Const64 [c])) // cond: uint64(c) >= 32 // result: (Const32 [0]) for { if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(uint64(c) >= 32) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Rsh32Ux64 <t> (Rsh32Ux64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Rsh32Ux64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpRsh32Ux64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Rsh32Ux64 (Rsh32x64 x _) (Const64 <t> [31])) // result: (Rsh32Ux64 x (Const64 <t> [31])) for { if v_0.Op != OpRsh32x64 { break } x := v_0.Args[0] if v_1.Op != OpConst64 { break } t := v_1.Type if auxIntToInt64(v_1.AuxInt) != 31 { break } v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(31) v.AddArg2(x, v0) return true } // match: (Rsh32Ux64 (Lsh32x64 (Rsh32Ux64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) // result: (Rsh32Ux64 x (Const64 <typ.UInt64> [c1-c2+c3])) for { if v_0.Op != OpLsh32x64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh32Ux64 { break } _ = v_0_0.Args[1] x := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c1 := auxIntToInt64(v_0_0_1.AuxInt) v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } c3 := auxIntToInt64(v_1.AuxInt) if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { break } v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) v.AddArg2(x, v0) return true } // match: (Rsh32Ux64 (Lsh32x64 x (Const64 [24])) (Const64 [24])) // result: (ZeroExt8to32 (Trunc32to8 <typ.UInt8> x)) for { if v_0.Op != OpLsh32x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 24 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 24 { break } v.reset(OpZeroExt8to32) v0 := b.NewValue0(v.Pos, OpTrunc32to8, typ.UInt8) v0.AddArg(x) v.AddArg(v0) return true } // match: (Rsh32Ux64 (Lsh32x64 x (Const64 [16])) (Const64 [16])) // result: (ZeroExt16to32 (Trunc32to16 <typ.UInt16> x)) for { if v_0.Op != OpLsh32x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 16 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 16 { break } v.reset(OpZeroExt16to32) v0 := b.NewValue0(v.Pos, OpTrunc32to16, typ.UInt16) v0.AddArg(x) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpRsh32Ux8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh32Ux8 <t> x (Const8 [c])) // result: (Rsh32Ux64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpRsh32Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Rsh32Ux8 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh32x16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh32x16 <t> x (Const16 [c])) // result: (Rsh32x64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpRsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Rsh32x16 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh32x32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh32x32 <t> x (Const32 [c])) // result: (Rsh32x64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpRsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Rsh32x32 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh32x64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Rsh32x64 (Const32 [c]) (Const64 [d])) // result: (Const32 [c >> uint64(d)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c >> uint64(d)) return true } // match: (Rsh32x64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Rsh32x64 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Rsh32x64 <t> (Rsh32x64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Rsh32x64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpRsh32x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpRsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Rsh32x64 (Lsh32x64 x (Const64 [24])) (Const64 [24])) // result: (SignExt8to32 (Trunc32to8 <typ.Int8> x)) for { if v_0.Op != OpLsh32x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 24 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 24 { break } v.reset(OpSignExt8to32) v0 := b.NewValue0(v.Pos, OpTrunc32to8, typ.Int8) v0.AddArg(x) v.AddArg(v0) return true } // match: (Rsh32x64 (Lsh32x64 x (Const64 [16])) (Const64 [16])) // result: (SignExt16to32 (Trunc32to16 <typ.Int16> x)) for { if v_0.Op != OpLsh32x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 16 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 16 { break } v.reset(OpSignExt16to32) v0 := b.NewValue0(v.Pos, OpTrunc32to16, typ.Int16) v0.AddArg(x) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpRsh32x8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh32x8 <t> x (Const8 [c])) // result: (Rsh32x64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpRsh32x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Rsh32x8 (Const32 [0]) _) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh64Ux16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh64Ux16 <t> x (Const16 [c])) // result: (Rsh64Ux64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Rsh64Ux16 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh64Ux32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh64Ux32 <t> x (Const32 [c])) // result: (Rsh64Ux64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Rsh64Ux32 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh64Ux64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Rsh64Ux64 (Const64 [c]) (Const64 [d])) // result: (Const64 [int64(uint64(c) >> uint64(d))]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(uint64(c) >> uint64(d))) return true } // match: (Rsh64Ux64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Rsh64Ux64 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Rsh64Ux64 _ (Const64 [c])) // cond: uint64(c) >= 64 // result: (Const64 [0]) for { if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(uint64(c) >= 64) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Rsh64Ux64 <t> (Rsh64Ux64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Rsh64Ux64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpRsh64Ux64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Rsh64Ux64 (Rsh64x64 x _) (Const64 <t> [63])) // result: (Rsh64Ux64 x (Const64 <t> [63])) for { if v_0.Op != OpRsh64x64 { break } x := v_0.Args[0] if v_1.Op != OpConst64 { break } t := v_1.Type if auxIntToInt64(v_1.AuxInt) != 63 { break } v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(63) v.AddArg2(x, v0) return true } // match: (Rsh64Ux64 (Lsh64x64 (Rsh64Ux64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) // result: (Rsh64Ux64 x (Const64 <typ.UInt64> [c1-c2+c3])) for { if v_0.Op != OpLsh64x64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh64Ux64 { break } _ = v_0_0.Args[1] x := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c1 := auxIntToInt64(v_0_0_1.AuxInt) v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } c3 := auxIntToInt64(v_1.AuxInt) if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { break } v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) v.AddArg2(x, v0) return true } // match: (Rsh64Ux64 (Lsh64x64 x (Const64 [56])) (Const64 [56])) // result: (ZeroExt8to64 (Trunc64to8 <typ.UInt8> x)) for { if v_0.Op != OpLsh64x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 56 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 56 { break } v.reset(OpZeroExt8to64) v0 := b.NewValue0(v.Pos, OpTrunc64to8, typ.UInt8) v0.AddArg(x) v.AddArg(v0) return true } // match: (Rsh64Ux64 (Lsh64x64 x (Const64 [48])) (Const64 [48])) // result: (ZeroExt16to64 (Trunc64to16 <typ.UInt16> x)) for { if v_0.Op != OpLsh64x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 48 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 48 { break } v.reset(OpZeroExt16to64) v0 := b.NewValue0(v.Pos, OpTrunc64to16, typ.UInt16) v0.AddArg(x) v.AddArg(v0) return true } // match: (Rsh64Ux64 (Lsh64x64 x (Const64 [32])) (Const64 [32])) // result: (ZeroExt32to64 (Trunc64to32 <typ.UInt32> x)) for { if v_0.Op != OpLsh64x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 32 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 32 { break } v.reset(OpZeroExt32to64) v0 := b.NewValue0(v.Pos, OpTrunc64to32, typ.UInt32) v0.AddArg(x) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpRsh64Ux8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh64Ux8 <t> x (Const8 [c])) // result: (Rsh64Ux64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpRsh64Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Rsh64Ux8 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh64x16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh64x16 <t> x (Const16 [c])) // result: (Rsh64x64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpRsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Rsh64x16 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh64x32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh64x32 <t> x (Const32 [c])) // result: (Rsh64x64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpRsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Rsh64x32 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh64x64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Rsh64x64 (Const64 [c]) (Const64 [d])) // result: (Const64 [c >> uint64(d)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c >> uint64(d)) return true } // match: (Rsh64x64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Rsh64x64 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Rsh64x64 <t> (Rsh64x64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Rsh64x64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpRsh64x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpRsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Rsh64x64 (Lsh64x64 x (Const64 [56])) (Const64 [56])) // result: (SignExt8to64 (Trunc64to8 <typ.Int8> x)) for { if v_0.Op != OpLsh64x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 56 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 56 { break } v.reset(OpSignExt8to64) v0 := b.NewValue0(v.Pos, OpTrunc64to8, typ.Int8) v0.AddArg(x) v.AddArg(v0) return true } // match: (Rsh64x64 (Lsh64x64 x (Const64 [48])) (Const64 [48])) // result: (SignExt16to64 (Trunc64to16 <typ.Int16> x)) for { if v_0.Op != OpLsh64x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 48 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 48 { break } v.reset(OpSignExt16to64) v0 := b.NewValue0(v.Pos, OpTrunc64to16, typ.Int16) v0.AddArg(x) v.AddArg(v0) return true } // match: (Rsh64x64 (Lsh64x64 x (Const64 [32])) (Const64 [32])) // result: (SignExt32to64 (Trunc64to32 <typ.Int32> x)) for { if v_0.Op != OpLsh64x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 || auxIntToInt64(v_0_1.AuxInt) != 32 || v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 32 { break } v.reset(OpSignExt32to64) v0 := b.NewValue0(v.Pos, OpTrunc64to32, typ.Int32) v0.AddArg(x) v.AddArg(v0) return true } return false } func rewriteValuegeneric_OpRsh64x8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh64x8 <t> x (Const8 [c])) // result: (Rsh64x64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpRsh64x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Rsh64x8 (Const64 [0]) _) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh8Ux16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh8Ux16 <t> x (Const16 [c])) // result: (Rsh8Ux64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Rsh8Ux16 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh8Ux32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh8Ux32 <t> x (Const32 [c])) // result: (Rsh8Ux64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Rsh8Ux32 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh8Ux64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block typ := &b.Func.Config.Types // match: (Rsh8Ux64 (Const8 [c]) (Const64 [d])) // result: (Const8 [int8(uint8(c) >> uint64(d))]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(int8(uint8(c) >> uint64(d))) return true } // match: (Rsh8Ux64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Rsh8Ux64 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (Rsh8Ux64 _ (Const64 [c])) // cond: uint64(c) >= 8 // result: (Const8 [0]) for { if v_1.Op != OpConst64 { break } c := auxIntToInt64(v_1.AuxInt) if !(uint64(c) >= 8) { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (Rsh8Ux64 <t> (Rsh8Ux64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Rsh8Ux64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpRsh8Ux64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } // match: (Rsh8Ux64 (Rsh8x64 x _) (Const64 <t> [7] )) // result: (Rsh8Ux64 x (Const64 <t> [7] )) for { if v_0.Op != OpRsh8x64 { break } x := v_0.Args[0] if v_1.Op != OpConst64 { break } t := v_1.Type if auxIntToInt64(v_1.AuxInt) != 7 { break } v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(7) v.AddArg2(x, v0) return true } // match: (Rsh8Ux64 (Lsh8x64 (Rsh8Ux64 x (Const64 [c1])) (Const64 [c2])) (Const64 [c3])) // cond: uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3) // result: (Rsh8Ux64 x (Const64 <typ.UInt64> [c1-c2+c3])) for { if v_0.Op != OpLsh8x64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpRsh8Ux64 { break } _ = v_0_0.Args[1] x := v_0_0.Args[0] v_0_0_1 := v_0_0.Args[1] if v_0_0_1.Op != OpConst64 { break } c1 := auxIntToInt64(v_0_0_1.AuxInt) v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c2 := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } c3 := auxIntToInt64(v_1.AuxInt) if !(uint64(c1) >= uint64(c2) && uint64(c3) >= uint64(c2) && !uaddOvf(c1-c2, c3)) { break } v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpConst64, typ.UInt64) v0.AuxInt = int64ToAuxInt(c1 - c2 + c3) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpRsh8Ux8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh8Ux8 <t> x (Const8 [c])) // result: (Rsh8Ux64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpRsh8Ux64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Rsh8Ux8 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh8x16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh8x16 <t> x (Const16 [c])) // result: (Rsh8x64 x (Const64 <t> [int64(uint16(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst16 { break } c := auxIntToInt16(v_1.AuxInt) v.reset(OpRsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint16(c))) v.AddArg2(x, v0) return true } // match: (Rsh8x16 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh8x32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh8x32 <t> x (Const32 [c])) // result: (Rsh8x64 x (Const64 <t> [int64(uint32(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst32 { break } c := auxIntToInt32(v_1.AuxInt) v.reset(OpRsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint32(c))) v.AddArg2(x, v0) return true } // match: (Rsh8x32 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpRsh8x64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh8x64 (Const8 [c]) (Const64 [d])) // result: (Const8 [c >> uint64(d)]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c >> uint64(d)) return true } // match: (Rsh8x64 x (Const64 [0])) // result: x for { x := v_0 if v_1.Op != OpConst64 || auxIntToInt64(v_1.AuxInt) != 0 { break } v.copyOf(x) return true } // match: (Rsh8x64 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (Rsh8x64 <t> (Rsh8x64 x (Const64 [c])) (Const64 [d])) // cond: !uaddOvf(c,d) // result: (Rsh8x64 x (Const64 <t> [c+d])) for { t := v.Type if v_0.Op != OpRsh8x64 { break } _ = v_0.Args[1] x := v_0.Args[0] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } c := auxIntToInt64(v_0_1.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) if !(!uaddOvf(c, d)) { break } v.reset(OpRsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(x, v0) return true } return false } func rewriteValuegeneric_OpRsh8x8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Rsh8x8 <t> x (Const8 [c])) // result: (Rsh8x64 x (Const64 <t> [int64(uint8(c))])) for { t := v.Type x := v_0 if v_1.Op != OpConst8 { break } c := auxIntToInt8(v_1.AuxInt) v.reset(OpRsh8x64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(int64(uint8(c))) v.AddArg2(x, v0) return true } // match: (Rsh8x8 (Const8 [0]) _) // result: (Const8 [0]) for { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpSelect0(v *Value) bool { v_0 := v.Args[0] // match: (Select0 (Div128u (Const64 [0]) lo y)) // result: (Div64u lo y) for { if v_0.Op != OpDiv128u { break } y := v_0.Args[2] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 || auxIntToInt64(v_0_0.AuxInt) != 0 { break } lo := v_0.Args[1] v.reset(OpDiv64u) v.AddArg2(lo, y) return true } return false } func rewriteValuegeneric_OpSelect1(v *Value) bool { v_0 := v.Args[0] // match: (Select1 (Div128u (Const64 [0]) lo y)) // result: (Mod64u lo y) for { if v_0.Op != OpDiv128u { break } y := v_0.Args[2] v_0_0 := v_0.Args[0] if v_0_0.Op != OpConst64 || auxIntToInt64(v_0_0.AuxInt) != 0 { break } lo := v_0.Args[1] v.reset(OpMod64u) v.AddArg2(lo, y) return true } return false } func rewriteValuegeneric_OpSignExt16to32(v *Value) bool { v_0 := v.Args[0] // match: (SignExt16to32 (Const16 [c])) // result: (Const32 [int32(c)]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(c)) return true } // match: (SignExt16to32 (Trunc32to16 x:(Rsh32x64 _ (Const64 [s])))) // cond: s >= 16 // result: x for { if v_0.Op != OpTrunc32to16 { break } x := v_0.Args[0] if x.Op != OpRsh32x64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 16) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpSignExt16to64(v *Value) bool { v_0 := v.Args[0] // match: (SignExt16to64 (Const16 [c])) // result: (Const64 [int64(c)]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(c)) return true } // match: (SignExt16to64 (Trunc64to16 x:(Rsh64x64 _ (Const64 [s])))) // cond: s >= 48 // result: x for { if v_0.Op != OpTrunc64to16 { break } x := v_0.Args[0] if x.Op != OpRsh64x64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 48) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpSignExt32to64(v *Value) bool { v_0 := v.Args[0] // match: (SignExt32to64 (Const32 [c])) // result: (Const64 [int64(c)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(c)) return true } // match: (SignExt32to64 (Trunc64to32 x:(Rsh64x64 _ (Const64 [s])))) // cond: s >= 32 // result: x for { if v_0.Op != OpTrunc64to32 { break } x := v_0.Args[0] if x.Op != OpRsh64x64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 32) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpSignExt8to16(v *Value) bool { v_0 := v.Args[0] // match: (SignExt8to16 (Const8 [c])) // result: (Const16 [int16(c)]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(int16(c)) return true } // match: (SignExt8to16 (Trunc16to8 x:(Rsh16x64 _ (Const64 [s])))) // cond: s >= 8 // result: x for { if v_0.Op != OpTrunc16to8 { break } x := v_0.Args[0] if x.Op != OpRsh16x64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 8) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpSignExt8to32(v *Value) bool { v_0 := v.Args[0] // match: (SignExt8to32 (Const8 [c])) // result: (Const32 [int32(c)]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(c)) return true } // match: (SignExt8to32 (Trunc32to8 x:(Rsh32x64 _ (Const64 [s])))) // cond: s >= 24 // result: x for { if v_0.Op != OpTrunc32to8 { break } x := v_0.Args[0] if x.Op != OpRsh32x64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 24) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpSignExt8to64(v *Value) bool { v_0 := v.Args[0] // match: (SignExt8to64 (Const8 [c])) // result: (Const64 [int64(c)]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(c)) return true } // match: (SignExt8to64 (Trunc64to8 x:(Rsh64x64 _ (Const64 [s])))) // cond: s >= 56 // result: x for { if v_0.Op != OpTrunc64to8 { break } x := v_0.Args[0] if x.Op != OpRsh64x64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 56) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpSliceCap(v *Value) bool { v_0 := v.Args[0] // match: (SliceCap (SliceMake _ _ (Const64 <t> [c]))) // result: (Const64 <t> [c]) for { if v_0.Op != OpSliceMake { break } _ = v_0.Args[2] v_0_2 := v_0.Args[2] if v_0_2.Op != OpConst64 { break } t := v_0_2.Type c := auxIntToInt64(v_0_2.AuxInt) v.reset(OpConst64) v.Type = t v.AuxInt = int64ToAuxInt(c) return true } // match: (SliceCap (SliceMake _ _ (Const32 <t> [c]))) // result: (Const32 <t> [c]) for { if v_0.Op != OpSliceMake { break } _ = v_0.Args[2] v_0_2 := v_0.Args[2] if v_0_2.Op != OpConst32 { break } t := v_0_2.Type c := auxIntToInt32(v_0_2.AuxInt) v.reset(OpConst32) v.Type = t v.AuxInt = int32ToAuxInt(c) return true } // match: (SliceCap (SliceMake _ _ (SliceCap x))) // result: (SliceCap x) for { if v_0.Op != OpSliceMake { break } _ = v_0.Args[2] v_0_2 := v_0.Args[2] if v_0_2.Op != OpSliceCap { break } x := v_0_2.Args[0] v.reset(OpSliceCap) v.AddArg(x) return true } // match: (SliceCap (SliceMake _ _ (SliceLen x))) // result: (SliceLen x) for { if v_0.Op != OpSliceMake { break } _ = v_0.Args[2] v_0_2 := v_0.Args[2] if v_0_2.Op != OpSliceLen { break } x := v_0_2.Args[0] v.reset(OpSliceLen) v.AddArg(x) return true } return false } func rewriteValuegeneric_OpSliceLen(v *Value) bool { v_0 := v.Args[0] // match: (SliceLen (SliceMake _ (Const64 <t> [c]) _)) // result: (Const64 <t> [c]) for { if v_0.Op != OpSliceMake { break } _ = v_0.Args[1] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } t := v_0_1.Type c := auxIntToInt64(v_0_1.AuxInt) v.reset(OpConst64) v.Type = t v.AuxInt = int64ToAuxInt(c) return true } // match: (SliceLen (SliceMake _ (Const32 <t> [c]) _)) // result: (Const32 <t> [c]) for { if v_0.Op != OpSliceMake { break } _ = v_0.Args[1] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst32 { break } t := v_0_1.Type c := auxIntToInt32(v_0_1.AuxInt) v.reset(OpConst32) v.Type = t v.AuxInt = int32ToAuxInt(c) return true } // match: (SliceLen (SliceMake _ (SliceLen x) _)) // result: (SliceLen x) for { if v_0.Op != OpSliceMake { break } _ = v_0.Args[1] v_0_1 := v_0.Args[1] if v_0_1.Op != OpSliceLen { break } x := v_0_1.Args[0] v.reset(OpSliceLen) v.AddArg(x) return true } return false } func rewriteValuegeneric_OpSlicePtr(v *Value) bool { v_0 := v.Args[0] // match: (SlicePtr (SliceMake (SlicePtr x) _ _)) // result: (SlicePtr x) for { if v_0.Op != OpSliceMake { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpSlicePtr { break } x := v_0_0.Args[0] v.reset(OpSlicePtr) v.AddArg(x) return true } return false } func rewriteValuegeneric_OpSlicemask(v *Value) bool { v_0 := v.Args[0] // match: (Slicemask (Const32 [x])) // cond: x > 0 // result: (Const32 [-1]) for { if v_0.Op != OpConst32 { break } x := auxIntToInt32(v_0.AuxInt) if !(x > 0) { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(-1) return true } // match: (Slicemask (Const32 [0])) // result: (Const32 [0]) for { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Slicemask (Const64 [x])) // cond: x > 0 // result: (Const64 [-1]) for { if v_0.Op != OpConst64 { break } x := auxIntToInt64(v_0.AuxInt) if !(x > 0) { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(-1) return true } // match: (Slicemask (Const64 [0])) // result: (Const64 [0]) for { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } return false } func rewriteValuegeneric_OpSqrt(v *Value) bool { v_0 := v.Args[0] // match: (Sqrt (Const64F [c])) // cond: !math.IsNaN(math.Sqrt(c)) // result: (Const64F [math.Sqrt(c)]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) if !(!math.IsNaN(math.Sqrt(c))) { break } v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(math.Sqrt(c)) return true } return false } func rewriteValuegeneric_OpStaticCall(v *Value) bool { v_0 := v.Args[0] b := v.Block config := b.Func.Config // match: (StaticCall {sym} s1:(Store _ (Const64 [sz]) s2:(Store _ src s3:(Store {t} _ dst mem)))) // cond: sz >= 0 && symNamed(sym, "runtime.memmove") && t.IsPtr() && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, int64(sz), config) && clobber(s1, s2, s3) // result: (Move {t.Elem()} [int64(sz)] dst src mem) for { sym := auxToSym(v.Aux) s1 := v_0 if s1.Op != OpStore { break } _ = s1.Args[2] s1_1 := s1.Args[1] if s1_1.Op != OpConst64 { break } sz := auxIntToInt64(s1_1.AuxInt) s2 := s1.Args[2] if s2.Op != OpStore { break } _ = s2.Args[2] src := s2.Args[1] s3 := s2.Args[2] if s3.Op != OpStore { break } t := auxToType(s3.Aux) mem := s3.Args[2] dst := s3.Args[1] if !(sz >= 0 && symNamed(sym, "runtime.memmove") && t.IsPtr() && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, int64(sz), config) && clobber(s1, s2, s3)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(int64(sz)) v.Aux = typeToAux(t.Elem()) v.AddArg3(dst, src, mem) return true } // match: (StaticCall {sym} s1:(Store _ (Const32 [sz]) s2:(Store _ src s3:(Store {t} _ dst mem)))) // cond: sz >= 0 && symNamed(sym, "runtime.memmove") && t.IsPtr() && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, int64(sz), config) && clobber(s1, s2, s3) // result: (Move {t.Elem()} [int64(sz)] dst src mem) for { sym := auxToSym(v.Aux) s1 := v_0 if s1.Op != OpStore { break } _ = s1.Args[2] s1_1 := s1.Args[1] if s1_1.Op != OpConst32 { break } sz := auxIntToInt32(s1_1.AuxInt) s2 := s1.Args[2] if s2.Op != OpStore { break } _ = s2.Args[2] src := s2.Args[1] s3 := s2.Args[2] if s3.Op != OpStore { break } t := auxToType(s3.Aux) mem := s3.Args[2] dst := s3.Args[1] if !(sz >= 0 && symNamed(sym, "runtime.memmove") && t.IsPtr() && s1.Uses == 1 && s2.Uses == 1 && s3.Uses == 1 && isInlinableMemmove(dst, src, int64(sz), config) && clobber(s1, s2, s3)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(int64(sz)) v.Aux = typeToAux(t.Elem()) v.AddArg3(dst, src, mem) return true } // match: (StaticCall {sym} x) // cond: needRaceCleanup(sym, v) // result: x for { sym := auxToSym(v.Aux) x := v_0 if !(needRaceCleanup(sym, v)) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpStore(v *Value) bool { v_2 := v.Args[2] v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config fe := b.Func.fe // match: (Store {t1} p1 (Load <t2> p2 mem) mem) // cond: isSamePtr(p1, p2) && t2.Size() == t1.Size() // result: mem for { t1 := auxToType(v.Aux) p1 := v_0 if v_1.Op != OpLoad { break } t2 := v_1.Type mem := v_1.Args[1] p2 := v_1.Args[0] if mem != v_2 || !(isSamePtr(p1, p2) && t2.Size() == t1.Size()) { break } v.copyOf(mem) return true } // match: (Store {t1} p1 (Load <t2> p2 oldmem) mem:(Store {t3} p3 _ oldmem)) // cond: isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) // result: mem for { t1 := auxToType(v.Aux) p1 := v_0 if v_1.Op != OpLoad { break } t2 := v_1.Type oldmem := v_1.Args[1] p2 := v_1.Args[0] mem := v_2 if mem.Op != OpStore { break } t3 := auxToType(mem.Aux) _ = mem.Args[2] p3 := mem.Args[0] if oldmem != mem.Args[2] || !(isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size())) { break } v.copyOf(mem) return true } // match: (Store {t1} p1 (Load <t2> p2 oldmem) mem:(Store {t3} p3 _ (Store {t4} p4 _ oldmem))) // cond: isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) && disjoint(p1, t1.Size(), p4, t4.Size()) // result: mem for { t1 := auxToType(v.Aux) p1 := v_0 if v_1.Op != OpLoad { break } t2 := v_1.Type oldmem := v_1.Args[1] p2 := v_1.Args[0] mem := v_2 if mem.Op != OpStore { break } t3 := auxToType(mem.Aux) _ = mem.Args[2] p3 := mem.Args[0] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t4 := auxToType(mem_2.Aux) _ = mem_2.Args[2] p4 := mem_2.Args[0] if oldmem != mem_2.Args[2] || !(isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) && disjoint(p1, t1.Size(), p4, t4.Size())) { break } v.copyOf(mem) return true } // match: (Store {t1} p1 (Load <t2> p2 oldmem) mem:(Store {t3} p3 _ (Store {t4} p4 _ (Store {t5} p5 _ oldmem)))) // cond: isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) && disjoint(p1, t1.Size(), p4, t4.Size()) && disjoint(p1, t1.Size(), p5, t5.Size()) // result: mem for { t1 := auxToType(v.Aux) p1 := v_0 if v_1.Op != OpLoad { break } t2 := v_1.Type oldmem := v_1.Args[1] p2 := v_1.Args[0] mem := v_2 if mem.Op != OpStore { break } t3 := auxToType(mem.Aux) _ = mem.Args[2] p3 := mem.Args[0] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t4 := auxToType(mem_2.Aux) _ = mem_2.Args[2] p4 := mem_2.Args[0] mem_2_2 := mem_2.Args[2] if mem_2_2.Op != OpStore { break } t5 := auxToType(mem_2_2.Aux) _ = mem_2_2.Args[2] p5 := mem_2_2.Args[0] if oldmem != mem_2_2.Args[2] || !(isSamePtr(p1, p2) && t2.Size() == t1.Size() && disjoint(p1, t1.Size(), p3, t3.Size()) && disjoint(p1, t1.Size(), p4, t4.Size()) && disjoint(p1, t1.Size(), p5, t5.Size())) { break } v.copyOf(mem) return true } // match: (Store {t} (OffPtr [o] p1) x mem:(Zero [n] p2 _)) // cond: isConstZero(x) && o >= 0 && t.Size() + o <= n && isSamePtr(p1, p2) // result: mem for { t := auxToType(v.Aux) if v_0.Op != OpOffPtr { break } o := auxIntToInt64(v_0.AuxInt) p1 := v_0.Args[0] x := v_1 mem := v_2 if mem.Op != OpZero { break } n := auxIntToInt64(mem.AuxInt) p2 := mem.Args[0] if !(isConstZero(x) && o >= 0 && t.Size()+o <= n && isSamePtr(p1, p2)) { break } v.copyOf(mem) return true } // match: (Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Zero [n] p3 _))) // cond: isConstZero(x) && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p3) && disjoint(op, t1.Size(), p2, t2.Size()) // result: mem for { t1 := auxToType(v.Aux) op := v_0 if op.Op != OpOffPtr { break } o1 := auxIntToInt64(op.AuxInt) p1 := op.Args[0] x := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] p2 := mem.Args[0] mem_2 := mem.Args[2] if mem_2.Op != OpZero { break } n := auxIntToInt64(mem_2.AuxInt) p3 := mem_2.Args[0] if !(isConstZero(x) && o1 >= 0 && t1.Size()+o1 <= n && isSamePtr(p1, p3) && disjoint(op, t1.Size(), p2, t2.Size())) { break } v.copyOf(mem) return true } // match: (Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Zero [n] p4 _)))) // cond: isConstZero(x) && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p4) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) // result: mem for { t1 := auxToType(v.Aux) op := v_0 if op.Op != OpOffPtr { break } o1 := auxIntToInt64(op.AuxInt) p1 := op.Args[0] x := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] p2 := mem.Args[0] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t3 := auxToType(mem_2.Aux) _ = mem_2.Args[2] p3 := mem_2.Args[0] mem_2_2 := mem_2.Args[2] if mem_2_2.Op != OpZero { break } n := auxIntToInt64(mem_2_2.AuxInt) p4 := mem_2_2.Args[0] if !(isConstZero(x) && o1 >= 0 && t1.Size()+o1 <= n && isSamePtr(p1, p4) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size())) { break } v.copyOf(mem) return true } // match: (Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Zero [n] p5 _))))) // cond: isConstZero(x) && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p5) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size()) // result: mem for { t1 := auxToType(v.Aux) op := v_0 if op.Op != OpOffPtr { break } o1 := auxIntToInt64(op.AuxInt) p1 := op.Args[0] x := v_1 mem := v_2 if mem.Op != OpStore { break } t2 := auxToType(mem.Aux) _ = mem.Args[2] p2 := mem.Args[0] mem_2 := mem.Args[2] if mem_2.Op != OpStore { break } t3 := auxToType(mem_2.Aux) _ = mem_2.Args[2] p3 := mem_2.Args[0] mem_2_2 := mem_2.Args[2] if mem_2_2.Op != OpStore { break } t4 := auxToType(mem_2_2.Aux) _ = mem_2_2.Args[2] p4 := mem_2_2.Args[0] mem_2_2_2 := mem_2_2.Args[2] if mem_2_2_2.Op != OpZero { break } n := auxIntToInt64(mem_2_2_2.AuxInt) p5 := mem_2_2_2.Args[0] if !(isConstZero(x) && o1 >= 0 && t1.Size()+o1 <= n && isSamePtr(p1, p5) && disjoint(op, t1.Size(), p2, t2.Size()) && disjoint(op, t1.Size(), p3, t3.Size()) && disjoint(op, t1.Size(), p4, t4.Size())) { break } v.copyOf(mem) return true } // match: (Store _ (StructMake0) mem) // result: mem for { if v_1.Op != OpStructMake0 { break } mem := v_2 v.copyOf(mem) return true } // match: (Store dst (StructMake1 <t> f0) mem) // result: (Store {t.FieldType(0)} (OffPtr <t.FieldType(0).PtrTo()> [0] dst) f0 mem) for { dst := v_0 if v_1.Op != OpStructMake1 { break } t := v_1.Type f0 := v_1.Args[0] mem := v_2 v.reset(OpStore) v.Aux = typeToAux(t.FieldType(0)) v0 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v0.AuxInt = int64ToAuxInt(0) v0.AddArg(dst) v.AddArg3(v0, f0, mem) return true } // match: (Store dst (StructMake2 <t> f0 f1) mem) // result: (Store {t.FieldType(1)} (OffPtr <t.FieldType(1).PtrTo()> [t.FieldOff(1)] dst) f1 (Store {t.FieldType(0)} (OffPtr <t.FieldType(0).PtrTo()> [0] dst) f0 mem)) for { dst := v_0 if v_1.Op != OpStructMake2 { break } t := v_1.Type f1 := v_1.Args[1] f0 := v_1.Args[0] mem := v_2 v.reset(OpStore) v.Aux = typeToAux(t.FieldType(1)) v0 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(1).PtrTo()) v0.AuxInt = int64ToAuxInt(t.FieldOff(1)) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t.FieldType(0)) v2 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v2.AuxInt = int64ToAuxInt(0) v2.AddArg(dst) v1.AddArg3(v2, f0, mem) v.AddArg3(v0, f1, v1) return true } // match: (Store dst (StructMake3 <t> f0 f1 f2) mem) // result: (Store {t.FieldType(2)} (OffPtr <t.FieldType(2).PtrTo()> [t.FieldOff(2)] dst) f2 (Store {t.FieldType(1)} (OffPtr <t.FieldType(1).PtrTo()> [t.FieldOff(1)] dst) f1 (Store {t.FieldType(0)} (OffPtr <t.FieldType(0).PtrTo()> [0] dst) f0 mem))) for { dst := v_0 if v_1.Op != OpStructMake3 { break } t := v_1.Type f2 := v_1.Args[2] f0 := v_1.Args[0] f1 := v_1.Args[1] mem := v_2 v.reset(OpStore) v.Aux = typeToAux(t.FieldType(2)) v0 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(2).PtrTo()) v0.AuxInt = int64ToAuxInt(t.FieldOff(2)) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t.FieldType(1)) v2 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(1).PtrTo()) v2.AuxInt = int64ToAuxInt(t.FieldOff(1)) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t.FieldType(0)) v4 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v4.AuxInt = int64ToAuxInt(0) v4.AddArg(dst) v3.AddArg3(v4, f0, mem) v1.AddArg3(v2, f1, v3) v.AddArg3(v0, f2, v1) return true } // match: (Store dst (StructMake4 <t> f0 f1 f2 f3) mem) // result: (Store {t.FieldType(3)} (OffPtr <t.FieldType(3).PtrTo()> [t.FieldOff(3)] dst) f3 (Store {t.FieldType(2)} (OffPtr <t.FieldType(2).PtrTo()> [t.FieldOff(2)] dst) f2 (Store {t.FieldType(1)} (OffPtr <t.FieldType(1).PtrTo()> [t.FieldOff(1)] dst) f1 (Store {t.FieldType(0)} (OffPtr <t.FieldType(0).PtrTo()> [0] dst) f0 mem)))) for { dst := v_0 if v_1.Op != OpStructMake4 { break } t := v_1.Type f3 := v_1.Args[3] f0 := v_1.Args[0] f1 := v_1.Args[1] f2 := v_1.Args[2] mem := v_2 v.reset(OpStore) v.Aux = typeToAux(t.FieldType(3)) v0 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(3).PtrTo()) v0.AuxInt = int64ToAuxInt(t.FieldOff(3)) v0.AddArg(dst) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t.FieldType(2)) v2 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(2).PtrTo()) v2.AuxInt = int64ToAuxInt(t.FieldOff(2)) v2.AddArg(dst) v3 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v3.Aux = typeToAux(t.FieldType(1)) v4 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(1).PtrTo()) v4.AuxInt = int64ToAuxInt(t.FieldOff(1)) v4.AddArg(dst) v5 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v5.Aux = typeToAux(t.FieldType(0)) v6 := b.NewValue0(v.Pos, OpOffPtr, t.FieldType(0).PtrTo()) v6.AuxInt = int64ToAuxInt(0) v6.AddArg(dst) v5.AddArg3(v6, f0, mem) v3.AddArg3(v4, f1, v5) v1.AddArg3(v2, f2, v3) v.AddArg3(v0, f3, v1) return true } // match: (Store {t} dst (Load src mem) mem) // cond: !fe.CanSSA(t) // result: (Move {t} [t.Size()] dst src mem) for { t := auxToType(v.Aux) dst := v_0 if v_1.Op != OpLoad { break } mem := v_1.Args[1] src := v_1.Args[0] if mem != v_2 || !(!fe.CanSSA(t)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(t.Size()) v.Aux = typeToAux(t) v.AddArg3(dst, src, mem) return true } // match: (Store {t} dst (Load src mem) (VarDef {x} mem)) // cond: !fe.CanSSA(t) // result: (Move {t} [t.Size()] dst src (VarDef {x} mem)) for { t := auxToType(v.Aux) dst := v_0 if v_1.Op != OpLoad { break } mem := v_1.Args[1] src := v_1.Args[0] if v_2.Op != OpVarDef { break } x := auxToSym(v_2.Aux) if mem != v_2.Args[0] || !(!fe.CanSSA(t)) { break } v.reset(OpMove) v.AuxInt = int64ToAuxInt(t.Size()) v.Aux = typeToAux(t) v0 := b.NewValue0(v.Pos, OpVarDef, types.TypeMem) v0.Aux = symToAux(x) v0.AddArg(mem) v.AddArg3(dst, src, v0) return true } // match: (Store _ (ArrayMake0) mem) // result: mem for { if v_1.Op != OpArrayMake0 { break } mem := v_2 v.copyOf(mem) return true } // match: (Store dst (ArrayMake1 e) mem) // result: (Store {e.Type} dst e mem) for { dst := v_0 if v_1.Op != OpArrayMake1 { break } e := v_1.Args[0] mem := v_2 v.reset(OpStore) v.Aux = typeToAux(e.Type) v.AddArg3(dst, e, mem) return true } // match: (Store (Load (OffPtr [c] (SP)) mem) x mem) // cond: isConstZero(x) && mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize // result: mem for { if v_0.Op != OpLoad { break } mem := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpOffPtr { break } c := auxIntToInt64(v_0_0.AuxInt) v_0_0_0 := v_0_0.Args[0] if v_0_0_0.Op != OpSP { break } x := v_1 if mem != v_2 || !(isConstZero(x) && mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize) { break } v.copyOf(mem) return true } // match: (Store (OffPtr (Load (OffPtr [c] (SP)) mem)) x mem) // cond: isConstZero(x) && mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize // result: mem for { if v_0.Op != OpOffPtr { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpLoad { break } mem := v_0_0.Args[1] v_0_0_0 := v_0_0.Args[0] if v_0_0_0.Op != OpOffPtr { break } c := auxIntToInt64(v_0_0_0.AuxInt) v_0_0_0_0 := v_0_0_0.Args[0] if v_0_0_0_0.Op != OpSP { break } x := v_1 if mem != v_2 || !(isConstZero(x) && mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize) { break } v.copyOf(mem) return true } // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [0] p2) d2 m3:(Move [n] p3 _ mem))) // cond: m2.Uses == 1 && m3.Uses == 1 && o1 == t2.Size() && n == t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && clobber(m2, m3) // result: (Store {t1} op1 d1 (Store {t2} op2 d2 mem)) for { t1 := auxToType(v.Aux) op1 := v_0 if op1.Op != OpOffPtr { break } o1 := auxIntToInt64(op1.AuxInt) p1 := op1.Args[0] d1 := v_1 m2 := v_2 if m2.Op != OpStore { break } t2 := auxToType(m2.Aux) _ = m2.Args[2] op2 := m2.Args[0] if op2.Op != OpOffPtr || auxIntToInt64(op2.AuxInt) != 0 { break } p2 := op2.Args[0] d2 := m2.Args[1] m3 := m2.Args[2] if m3.Op != OpMove { break } n := auxIntToInt64(m3.AuxInt) mem := m3.Args[2] p3 := m3.Args[0] if !(m2.Uses == 1 && m3.Uses == 1 && o1 == t2.Size() && n == t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && clobber(m2, m3)) { break } v.reset(OpStore) v.Aux = typeToAux(t1) v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v0.Aux = typeToAux(t2) v0.AddArg3(op2, d2, mem) v.AddArg3(op1, d1, v0) return true } // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [o2] p2) d2 m3:(Store {t3} op3:(OffPtr [0] p3) d3 m4:(Move [n] p4 _ mem)))) // cond: m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && o2 == t3.Size() && o1-o2 == t2.Size() && n == t3.Size() + t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && clobber(m2, m3, m4) // result: (Store {t1} op1 d1 (Store {t2} op2 d2 (Store {t3} op3 d3 mem))) for { t1 := auxToType(v.Aux) op1 := v_0 if op1.Op != OpOffPtr { break } o1 := auxIntToInt64(op1.AuxInt) p1 := op1.Args[0] d1 := v_1 m2 := v_2 if m2.Op != OpStore { break } t2 := auxToType(m2.Aux) _ = m2.Args[2] op2 := m2.Args[0] if op2.Op != OpOffPtr { break } o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d2 := m2.Args[1] m3 := m2.Args[2] if m3.Op != OpStore { break } t3 := auxToType(m3.Aux) _ = m3.Args[2] op3 := m3.Args[0] if op3.Op != OpOffPtr || auxIntToInt64(op3.AuxInt) != 0 { break } p3 := op3.Args[0] d3 := m3.Args[1] m4 := m3.Args[2] if m4.Op != OpMove { break } n := auxIntToInt64(m4.AuxInt) mem := m4.Args[2] p4 := m4.Args[0] if !(m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && o2 == t3.Size() && o1-o2 == t2.Size() && n == t3.Size()+t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && clobber(m2, m3, m4)) { break } v.reset(OpStore) v.Aux = typeToAux(t1) v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v0.Aux = typeToAux(t2) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v1.AddArg3(op3, d3, mem) v0.AddArg3(op2, d2, v1) v.AddArg3(op1, d1, v0) return true } // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [o2] p2) d2 m3:(Store {t3} op3:(OffPtr [o3] p3) d3 m4:(Store {t4} op4:(OffPtr [0] p4) d4 m5:(Move [n] p5 _ mem))))) // cond: m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && m5.Uses == 1 && o3 == t4.Size() && o2-o3 == t3.Size() && o1-o2 == t2.Size() && n == t4.Size() + t3.Size() + t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && clobber(m2, m3, m4, m5) // result: (Store {t1} op1 d1 (Store {t2} op2 d2 (Store {t3} op3 d3 (Store {t4} op4 d4 mem)))) for { t1 := auxToType(v.Aux) op1 := v_0 if op1.Op != OpOffPtr { break } o1 := auxIntToInt64(op1.AuxInt) p1 := op1.Args[0] d1 := v_1 m2 := v_2 if m2.Op != OpStore { break } t2 := auxToType(m2.Aux) _ = m2.Args[2] op2 := m2.Args[0] if op2.Op != OpOffPtr { break } o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d2 := m2.Args[1] m3 := m2.Args[2] if m3.Op != OpStore { break } t3 := auxToType(m3.Aux) _ = m3.Args[2] op3 := m3.Args[0] if op3.Op != OpOffPtr { break } o3 := auxIntToInt64(op3.AuxInt) p3 := op3.Args[0] d3 := m3.Args[1] m4 := m3.Args[2] if m4.Op != OpStore { break } t4 := auxToType(m4.Aux) _ = m4.Args[2] op4 := m4.Args[0] if op4.Op != OpOffPtr || auxIntToInt64(op4.AuxInt) != 0 { break } p4 := op4.Args[0] d4 := m4.Args[1] m5 := m4.Args[2] if m5.Op != OpMove { break } n := auxIntToInt64(m5.AuxInt) mem := m5.Args[2] p5 := m5.Args[0] if !(m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && m5.Uses == 1 && o3 == t4.Size() && o2-o3 == t3.Size() && o1-o2 == t2.Size() && n == t4.Size()+t3.Size()+t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && clobber(m2, m3, m4, m5)) { break } v.reset(OpStore) v.Aux = typeToAux(t1) v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v0.Aux = typeToAux(t2) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v2.Aux = typeToAux(t4) v2.AddArg3(op4, d4, mem) v1.AddArg3(op3, d3, v2) v0.AddArg3(op2, d2, v1) v.AddArg3(op1, d1, v0) return true } // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [0] p2) d2 m3:(Zero [n] p3 mem))) // cond: m2.Uses == 1 && m3.Uses == 1 && o1 == t2.Size() && n == t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && clobber(m2, m3) // result: (Store {t1} op1 d1 (Store {t2} op2 d2 mem)) for { t1 := auxToType(v.Aux) op1 := v_0 if op1.Op != OpOffPtr { break } o1 := auxIntToInt64(op1.AuxInt) p1 := op1.Args[0] d1 := v_1 m2 := v_2 if m2.Op != OpStore { break } t2 := auxToType(m2.Aux) _ = m2.Args[2] op2 := m2.Args[0] if op2.Op != OpOffPtr || auxIntToInt64(op2.AuxInt) != 0 { break } p2 := op2.Args[0] d2 := m2.Args[1] m3 := m2.Args[2] if m3.Op != OpZero { break } n := auxIntToInt64(m3.AuxInt) mem := m3.Args[1] p3 := m3.Args[0] if !(m2.Uses == 1 && m3.Uses == 1 && o1 == t2.Size() && n == t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && clobber(m2, m3)) { break } v.reset(OpStore) v.Aux = typeToAux(t1) v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v0.Aux = typeToAux(t2) v0.AddArg3(op2, d2, mem) v.AddArg3(op1, d1, v0) return true } // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [o2] p2) d2 m3:(Store {t3} op3:(OffPtr [0] p3) d3 m4:(Zero [n] p4 mem)))) // cond: m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && o2 == t3.Size() && o1-o2 == t2.Size() && n == t3.Size() + t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && clobber(m2, m3, m4) // result: (Store {t1} op1 d1 (Store {t2} op2 d2 (Store {t3} op3 d3 mem))) for { t1 := auxToType(v.Aux) op1 := v_0 if op1.Op != OpOffPtr { break } o1 := auxIntToInt64(op1.AuxInt) p1 := op1.Args[0] d1 := v_1 m2 := v_2 if m2.Op != OpStore { break } t2 := auxToType(m2.Aux) _ = m2.Args[2] op2 := m2.Args[0] if op2.Op != OpOffPtr { break } o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d2 := m2.Args[1] m3 := m2.Args[2] if m3.Op != OpStore { break } t3 := auxToType(m3.Aux) _ = m3.Args[2] op3 := m3.Args[0] if op3.Op != OpOffPtr || auxIntToInt64(op3.AuxInt) != 0 { break } p3 := op3.Args[0] d3 := m3.Args[1] m4 := m3.Args[2] if m4.Op != OpZero { break } n := auxIntToInt64(m4.AuxInt) mem := m4.Args[1] p4 := m4.Args[0] if !(m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && o2 == t3.Size() && o1-o2 == t2.Size() && n == t3.Size()+t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && clobber(m2, m3, m4)) { break } v.reset(OpStore) v.Aux = typeToAux(t1) v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v0.Aux = typeToAux(t2) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v1.AddArg3(op3, d3, mem) v0.AddArg3(op2, d2, v1) v.AddArg3(op1, d1, v0) return true } // match: (Store {t1} op1:(OffPtr [o1] p1) d1 m2:(Store {t2} op2:(OffPtr [o2] p2) d2 m3:(Store {t3} op3:(OffPtr [o3] p3) d3 m4:(Store {t4} op4:(OffPtr [0] p4) d4 m5:(Zero [n] p5 mem))))) // cond: m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && m5.Uses == 1 && o3 == t4.Size() && o2-o3 == t3.Size() && o1-o2 == t2.Size() && n == t4.Size() + t3.Size() + t2.Size() + t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && clobber(m2, m3, m4, m5) // result: (Store {t1} op1 d1 (Store {t2} op2 d2 (Store {t3} op3 d3 (Store {t4} op4 d4 mem)))) for { t1 := auxToType(v.Aux) op1 := v_0 if op1.Op != OpOffPtr { break } o1 := auxIntToInt64(op1.AuxInt) p1 := op1.Args[0] d1 := v_1 m2 := v_2 if m2.Op != OpStore { break } t2 := auxToType(m2.Aux) _ = m2.Args[2] op2 := m2.Args[0] if op2.Op != OpOffPtr { break } o2 := auxIntToInt64(op2.AuxInt) p2 := op2.Args[0] d2 := m2.Args[1] m3 := m2.Args[2] if m3.Op != OpStore { break } t3 := auxToType(m3.Aux) _ = m3.Args[2] op3 := m3.Args[0] if op3.Op != OpOffPtr { break } o3 := auxIntToInt64(op3.AuxInt) p3 := op3.Args[0] d3 := m3.Args[1] m4 := m3.Args[2] if m4.Op != OpStore { break } t4 := auxToType(m4.Aux) _ = m4.Args[2] op4 := m4.Args[0] if op4.Op != OpOffPtr || auxIntToInt64(op4.AuxInt) != 0 { break } p4 := op4.Args[0] d4 := m4.Args[1] m5 := m4.Args[2] if m5.Op != OpZero { break } n := auxIntToInt64(m5.AuxInt) mem := m5.Args[1] p5 := m5.Args[0] if !(m2.Uses == 1 && m3.Uses == 1 && m4.Uses == 1 && m5.Uses == 1 && o3 == t4.Size() && o2-o3 == t3.Size() && o1-o2 == t2.Size() && n == t4.Size()+t3.Size()+t2.Size()+t1.Size() && isSamePtr(p1, p2) && isSamePtr(p2, p3) && isSamePtr(p3, p4) && isSamePtr(p4, p5) && clobber(m2, m3, m4, m5)) { break } v.reset(OpStore) v.Aux = typeToAux(t1) v0 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v0.Aux = typeToAux(t2) v1 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v1.Aux = typeToAux(t3) v2 := b.NewValue0(v.Pos, OpStore, types.TypeMem) v2.Aux = typeToAux(t4) v2.AddArg3(op4, d4, mem) v1.AddArg3(op3, d3, v2) v0.AddArg3(op2, d2, v1) v.AddArg3(op1, d1, v0) return true } return false } func rewriteValuegeneric_OpStringLen(v *Value) bool { v_0 := v.Args[0] // match: (StringLen (StringMake _ (Const64 <t> [c]))) // result: (Const64 <t> [c]) for { if v_0.Op != OpStringMake { break } _ = v_0.Args[1] v_0_1 := v_0.Args[1] if v_0_1.Op != OpConst64 { break } t := v_0_1.Type c := auxIntToInt64(v_0_1.AuxInt) v.reset(OpConst64) v.Type = t v.AuxInt = int64ToAuxInt(c) return true } return false } func rewriteValuegeneric_OpStringPtr(v *Value) bool { v_0 := v.Args[0] // match: (StringPtr (StringMake (Addr <t> {s} base) _)) // result: (Addr <t> {s} base) for { if v_0.Op != OpStringMake { break } v_0_0 := v_0.Args[0] if v_0_0.Op != OpAddr { break } t := v_0_0.Type s := auxToSym(v_0_0.Aux) base := v_0_0.Args[0] v.reset(OpAddr) v.Type = t v.Aux = symToAux(s) v.AddArg(base) return true } return false } func rewriteValuegeneric_OpStructSelect(v *Value) bool { v_0 := v.Args[0] b := v.Block fe := b.Func.fe // match: (StructSelect (StructMake1 x)) // result: x for { if v_0.Op != OpStructMake1 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (StructSelect [0] (StructMake2 x _)) // result: x for { if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpStructMake2 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (StructSelect [1] (StructMake2 _ x)) // result: x for { if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpStructMake2 { break } x := v_0.Args[1] v.copyOf(x) return true } // match: (StructSelect [0] (StructMake3 x _ _)) // result: x for { if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpStructMake3 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (StructSelect [1] (StructMake3 _ x _)) // result: x for { if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpStructMake3 { break } x := v_0.Args[1] v.copyOf(x) return true } // match: (StructSelect [2] (StructMake3 _ _ x)) // result: x for { if auxIntToInt64(v.AuxInt) != 2 || v_0.Op != OpStructMake3 { break } x := v_0.Args[2] v.copyOf(x) return true } // match: (StructSelect [0] (StructMake4 x _ _ _)) // result: x for { if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpStructMake4 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (StructSelect [1] (StructMake4 _ x _ _)) // result: x for { if auxIntToInt64(v.AuxInt) != 1 || v_0.Op != OpStructMake4 { break } x := v_0.Args[1] v.copyOf(x) return true } // match: (StructSelect [2] (StructMake4 _ _ x _)) // result: x for { if auxIntToInt64(v.AuxInt) != 2 || v_0.Op != OpStructMake4 { break } x := v_0.Args[2] v.copyOf(x) return true } // match: (StructSelect [3] (StructMake4 _ _ _ x)) // result: x for { if auxIntToInt64(v.AuxInt) != 3 || v_0.Op != OpStructMake4 { break } x := v_0.Args[3] v.copyOf(x) return true } // match: (StructSelect [i] x:(Load <t> ptr mem)) // cond: !fe.CanSSA(t) // result: @x.Block (Load <v.Type> (OffPtr <v.Type.PtrTo()> [t.FieldOff(int(i))] ptr) mem) for { i := auxIntToInt64(v.AuxInt) x := v_0 if x.Op != OpLoad { break } t := x.Type mem := x.Args[1] ptr := x.Args[0] if !(!fe.CanSSA(t)) { break } b = x.Block v0 := b.NewValue0(v.Pos, OpLoad, v.Type) v.copyOf(v0) v1 := b.NewValue0(v.Pos, OpOffPtr, v.Type.PtrTo()) v1.AuxInt = int64ToAuxInt(t.FieldOff(int(i))) v1.AddArg(ptr) v0.AddArg2(v1, mem) return true } // match: (StructSelect [0] (IData x)) // result: (IData x) for { if auxIntToInt64(v.AuxInt) != 0 || v_0.Op != OpIData { break } x := v_0.Args[0] v.reset(OpIData) v.AddArg(x) return true } return false } func rewriteValuegeneric_OpSub16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Sub16 (Const16 [c]) (Const16 [d])) // result: (Const16 [c-d]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { break } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c - d) return true } // match: (Sub16 x (Const16 <t> [c])) // cond: x.Op != OpConst16 // result: (Add16 (Const16 <t> [-c]) x) for { x := v_0 if v_1.Op != OpConst16 { break } t := v_1.Type c := auxIntToInt16(v_1.AuxInt) if !(x.Op != OpConst16) { break } v.reset(OpAdd16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(-c) v.AddArg2(v0, x) return true } // match: (Sub16 <t> (Mul16 x y) (Mul16 x z)) // result: (Mul16 x (Sub16 <t> y z)) for { t := v.Type if v_0.Op != OpMul16 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if v_1.Op != OpMul16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } z := v_1_1 v.reset(OpMul16) v0 := b.NewValue0(v.Pos, OpSub16, t) v0.AddArg2(y, z) v.AddArg2(x, v0) return true } } break } // match: (Sub16 x x) // result: (Const16 [0]) for { x := v_0 if x != v_1 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } // match: (Sub16 (Add16 x y) x) // result: y for { if v_0.Op != OpAdd16 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if x != v_1 { continue } v.copyOf(y) return true } break } // match: (Sub16 (Add16 x y) y) // result: x for { if v_0.Op != OpAdd16 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if y != v_1 { continue } v.copyOf(x) return true } break } // match: (Sub16 x (Sub16 i:(Const16 <t>) z)) // cond: (z.Op != OpConst16 && x.Op != OpConst16) // result: (Sub16 (Add16 <t> x z) i) for { x := v_0 if v_1.Op != OpSub16 { break } z := v_1.Args[1] i := v_1.Args[0] if i.Op != OpConst16 { break } t := i.Type if !(z.Op != OpConst16 && x.Op != OpConst16) { break } v.reset(OpSub16) v0 := b.NewValue0(v.Pos, OpAdd16, t) v0.AddArg2(x, z) v.AddArg2(v0, i) return true } // match: (Sub16 x (Sub16 z i:(Const16 <t>))) // cond: (z.Op != OpConst16 && x.Op != OpConst16) // result: (Add16 i (Sub16 <t> x z)) for { x := v_0 if v_1.Op != OpSub16 { break } _ = v_1.Args[1] z := v_1.Args[0] i := v_1.Args[1] if i.Op != OpConst16 { break } t := i.Type if !(z.Op != OpConst16 && x.Op != OpConst16) { break } v.reset(OpAdd16) v0 := b.NewValue0(v.Pos, OpSub16, t) v0.AddArg2(x, z) v.AddArg2(i, v0) return true } // match: (Sub16 (Const16 <t> [c]) (Sub16 x (Const16 <t> [d]))) // result: (Sub16 (Const16 <t> [c+d]) x) for { if v_0.Op != OpConst16 { break } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpSub16 { break } _ = v_1.Args[1] x := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst16 || v_1_1.Type != t { break } d := auxIntToInt16(v_1_1.AuxInt) v.reset(OpSub16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c + d) v.AddArg2(v0, x) return true } // match: (Sub16 (Const16 <t> [c]) (Sub16 (Const16 <t> [d]) x)) // result: (Add16 (Const16 <t> [c-d]) x) for { if v_0.Op != OpConst16 { break } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpSub16 { break } x := v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpConst16 || v_1_0.Type != t { break } d := auxIntToInt16(v_1_0.AuxInt) v.reset(OpAdd16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c - d) v.AddArg2(v0, x) return true } return false } func rewriteValuegeneric_OpSub32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Sub32 (Const32 [c]) (Const32 [d])) // result: (Const32 [c-d]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { break } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c - d) return true } // match: (Sub32 x (Const32 <t> [c])) // cond: x.Op != OpConst32 // result: (Add32 (Const32 <t> [-c]) x) for { x := v_0 if v_1.Op != OpConst32 { break } t := v_1.Type c := auxIntToInt32(v_1.AuxInt) if !(x.Op != OpConst32) { break } v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(-c) v.AddArg2(v0, x) return true } // match: (Sub32 <t> (Mul32 x y) (Mul32 x z)) // result: (Mul32 x (Sub32 <t> y z)) for { t := v.Type if v_0.Op != OpMul32 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if v_1.Op != OpMul32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } z := v_1_1 v.reset(OpMul32) v0 := b.NewValue0(v.Pos, OpSub32, t) v0.AddArg2(y, z) v.AddArg2(x, v0) return true } } break } // match: (Sub32 x x) // result: (Const32 [0]) for { x := v_0 if x != v_1 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Sub32 (Add32 x y) x) // result: y for { if v_0.Op != OpAdd32 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if x != v_1 { continue } v.copyOf(y) return true } break } // match: (Sub32 (Add32 x y) y) // result: x for { if v_0.Op != OpAdd32 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if y != v_1 { continue } v.copyOf(x) return true } break } // match: (Sub32 x (Sub32 i:(Const32 <t>) z)) // cond: (z.Op != OpConst32 && x.Op != OpConst32) // result: (Sub32 (Add32 <t> x z) i) for { x := v_0 if v_1.Op != OpSub32 { break } z := v_1.Args[1] i := v_1.Args[0] if i.Op != OpConst32 { break } t := i.Type if !(z.Op != OpConst32 && x.Op != OpConst32) { break } v.reset(OpSub32) v0 := b.NewValue0(v.Pos, OpAdd32, t) v0.AddArg2(x, z) v.AddArg2(v0, i) return true } // match: (Sub32 x (Sub32 z i:(Const32 <t>))) // cond: (z.Op != OpConst32 && x.Op != OpConst32) // result: (Add32 i (Sub32 <t> x z)) for { x := v_0 if v_1.Op != OpSub32 { break } _ = v_1.Args[1] z := v_1.Args[0] i := v_1.Args[1] if i.Op != OpConst32 { break } t := i.Type if !(z.Op != OpConst32 && x.Op != OpConst32) { break } v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpSub32, t) v0.AddArg2(x, z) v.AddArg2(i, v0) return true } // match: (Sub32 (Const32 <t> [c]) (Sub32 x (Const32 <t> [d]))) // result: (Sub32 (Const32 <t> [c+d]) x) for { if v_0.Op != OpConst32 { break } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpSub32 { break } _ = v_1.Args[1] x := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst32 || v_1_1.Type != t { break } d := auxIntToInt32(v_1_1.AuxInt) v.reset(OpSub32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c + d) v.AddArg2(v0, x) return true } // match: (Sub32 (Const32 <t> [c]) (Sub32 (Const32 <t> [d]) x)) // result: (Add32 (Const32 <t> [c-d]) x) for { if v_0.Op != OpConst32 { break } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpSub32 { break } x := v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpConst32 || v_1_0.Type != t { break } d := auxIntToInt32(v_1_0.AuxInt) v.reset(OpAdd32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c - d) v.AddArg2(v0, x) return true } return false } func rewriteValuegeneric_OpSub32F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Sub32F (Const32F [c]) (Const32F [d])) // cond: c-d == c-d // result: (Const32F [c-d]) for { if v_0.Op != OpConst32F { break } c := auxIntToFloat32(v_0.AuxInt) if v_1.Op != OpConst32F { break } d := auxIntToFloat32(v_1.AuxInt) if !(c-d == c-d) { break } v.reset(OpConst32F) v.AuxInt = float32ToAuxInt(c - d) return true } return false } func rewriteValuegeneric_OpSub64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Sub64 (Const64 [c]) (Const64 [d])) // result: (Const64 [c-d]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { break } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c - d) return true } // match: (Sub64 x (Const64 <t> [c])) // cond: x.Op != OpConst64 // result: (Add64 (Const64 <t> [-c]) x) for { x := v_0 if v_1.Op != OpConst64 { break } t := v_1.Type c := auxIntToInt64(v_1.AuxInt) if !(x.Op != OpConst64) { break } v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(-c) v.AddArg2(v0, x) return true } // match: (Sub64 <t> (Mul64 x y) (Mul64 x z)) // result: (Mul64 x (Sub64 <t> y z)) for { t := v.Type if v_0.Op != OpMul64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if v_1.Op != OpMul64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } z := v_1_1 v.reset(OpMul64) v0 := b.NewValue0(v.Pos, OpSub64, t) v0.AddArg2(y, z) v.AddArg2(x, v0) return true } } break } // match: (Sub64 x x) // result: (Const64 [0]) for { x := v_0 if x != v_1 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Sub64 (Add64 x y) x) // result: y for { if v_0.Op != OpAdd64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if x != v_1 { continue } v.copyOf(y) return true } break } // match: (Sub64 (Add64 x y) y) // result: x for { if v_0.Op != OpAdd64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if y != v_1 { continue } v.copyOf(x) return true } break } // match: (Sub64 x (Sub64 i:(Const64 <t>) z)) // cond: (z.Op != OpConst64 && x.Op != OpConst64) // result: (Sub64 (Add64 <t> x z) i) for { x := v_0 if v_1.Op != OpSub64 { break } z := v_1.Args[1] i := v_1.Args[0] if i.Op != OpConst64 { break } t := i.Type if !(z.Op != OpConst64 && x.Op != OpConst64) { break } v.reset(OpSub64) v0 := b.NewValue0(v.Pos, OpAdd64, t) v0.AddArg2(x, z) v.AddArg2(v0, i) return true } // match: (Sub64 x (Sub64 z i:(Const64 <t>))) // cond: (z.Op != OpConst64 && x.Op != OpConst64) // result: (Add64 i (Sub64 <t> x z)) for { x := v_0 if v_1.Op != OpSub64 { break } _ = v_1.Args[1] z := v_1.Args[0] i := v_1.Args[1] if i.Op != OpConst64 { break } t := i.Type if !(z.Op != OpConst64 && x.Op != OpConst64) { break } v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpSub64, t) v0.AddArg2(x, z) v.AddArg2(i, v0) return true } // match: (Sub64 (Const64 <t> [c]) (Sub64 x (Const64 <t> [d]))) // result: (Sub64 (Const64 <t> [c+d]) x) for { if v_0.Op != OpConst64 { break } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpSub64 { break } _ = v_1.Args[1] x := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst64 || v_1_1.Type != t { break } d := auxIntToInt64(v_1_1.AuxInt) v.reset(OpSub64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c + d) v.AddArg2(v0, x) return true } // match: (Sub64 (Const64 <t> [c]) (Sub64 (Const64 <t> [d]) x)) // result: (Add64 (Const64 <t> [c-d]) x) for { if v_0.Op != OpConst64 { break } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpSub64 { break } x := v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpConst64 || v_1_0.Type != t { break } d := auxIntToInt64(v_1_0.AuxInt) v.reset(OpAdd64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c - d) v.AddArg2(v0, x) return true } return false } func rewriteValuegeneric_OpSub64F(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] // match: (Sub64F (Const64F [c]) (Const64F [d])) // cond: c-d == c-d // result: (Const64F [c-d]) for { if v_0.Op != OpConst64F { break } c := auxIntToFloat64(v_0.AuxInt) if v_1.Op != OpConst64F { break } d := auxIntToFloat64(v_1.AuxInt) if !(c-d == c-d) { break } v.reset(OpConst64F) v.AuxInt = float64ToAuxInt(c - d) return true } return false } func rewriteValuegeneric_OpSub8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Sub8 (Const8 [c]) (Const8 [d])) // result: (Const8 [c-d]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { break } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c - d) return true } // match: (Sub8 x (Const8 <t> [c])) // cond: x.Op != OpConst8 // result: (Add8 (Const8 <t> [-c]) x) for { x := v_0 if v_1.Op != OpConst8 { break } t := v_1.Type c := auxIntToInt8(v_1.AuxInt) if !(x.Op != OpConst8) { break } v.reset(OpAdd8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(-c) v.AddArg2(v0, x) return true } // match: (Sub8 <t> (Mul8 x y) (Mul8 x z)) // result: (Mul8 x (Sub8 <t> y z)) for { t := v.Type if v_0.Op != OpMul8 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if v_1.Op != OpMul8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } z := v_1_1 v.reset(OpMul8) v0 := b.NewValue0(v.Pos, OpSub8, t) v0.AddArg2(y, z) v.AddArg2(x, v0) return true } } break } // match: (Sub8 x x) // result: (Const8 [0]) for { x := v_0 if x != v_1 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (Sub8 (Add8 x y) x) // result: y for { if v_0.Op != OpAdd8 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if x != v_1 { continue } v.copyOf(y) return true } break } // match: (Sub8 (Add8 x y) y) // result: x for { if v_0.Op != OpAdd8 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { x := v_0_0 y := v_0_1 if y != v_1 { continue } v.copyOf(x) return true } break } // match: (Sub8 x (Sub8 i:(Const8 <t>) z)) // cond: (z.Op != OpConst8 && x.Op != OpConst8) // result: (Sub8 (Add8 <t> x z) i) for { x := v_0 if v_1.Op != OpSub8 { break } z := v_1.Args[1] i := v_1.Args[0] if i.Op != OpConst8 { break } t := i.Type if !(z.Op != OpConst8 && x.Op != OpConst8) { break } v.reset(OpSub8) v0 := b.NewValue0(v.Pos, OpAdd8, t) v0.AddArg2(x, z) v.AddArg2(v0, i) return true } // match: (Sub8 x (Sub8 z i:(Const8 <t>))) // cond: (z.Op != OpConst8 && x.Op != OpConst8) // result: (Add8 i (Sub8 <t> x z)) for { x := v_0 if v_1.Op != OpSub8 { break } _ = v_1.Args[1] z := v_1.Args[0] i := v_1.Args[1] if i.Op != OpConst8 { break } t := i.Type if !(z.Op != OpConst8 && x.Op != OpConst8) { break } v.reset(OpAdd8) v0 := b.NewValue0(v.Pos, OpSub8, t) v0.AddArg2(x, z) v.AddArg2(i, v0) return true } // match: (Sub8 (Const8 <t> [c]) (Sub8 x (Const8 <t> [d]))) // result: (Sub8 (Const8 <t> [c+d]) x) for { if v_0.Op != OpConst8 { break } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpSub8 { break } _ = v_1.Args[1] x := v_1.Args[0] v_1_1 := v_1.Args[1] if v_1_1.Op != OpConst8 || v_1_1.Type != t { break } d := auxIntToInt8(v_1_1.AuxInt) v.reset(OpSub8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c + d) v.AddArg2(v0, x) return true } // match: (Sub8 (Const8 <t> [c]) (Sub8 (Const8 <t> [d]) x)) // result: (Add8 (Const8 <t> [c-d]) x) for { if v_0.Op != OpConst8 { break } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpSub8 { break } x := v_1.Args[1] v_1_0 := v_1.Args[0] if v_1_0.Op != OpConst8 || v_1_0.Type != t { break } d := auxIntToInt8(v_1_0.AuxInt) v.reset(OpAdd8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c - d) v.AddArg2(v0, x) return true } return false } func rewriteValuegeneric_OpTrunc16to8(v *Value) bool { v_0 := v.Args[0] // match: (Trunc16to8 (Const16 [c])) // result: (Const8 [int8(c)]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(int8(c)) return true } // match: (Trunc16to8 (ZeroExt8to16 x)) // result: x for { if v_0.Op != OpZeroExt8to16 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc16to8 (SignExt8to16 x)) // result: x for { if v_0.Op != OpSignExt8to16 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc16to8 (And16 (Const16 [y]) x)) // cond: y&0xFF == 0xFF // result: (Trunc16to8 x) for { if v_0.Op != OpAnd16 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst16 { continue } y := auxIntToInt16(v_0_0.AuxInt) x := v_0_1 if !(y&0xFF == 0xFF) { continue } v.reset(OpTrunc16to8) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpTrunc32to16(v *Value) bool { v_0 := v.Args[0] // match: (Trunc32to16 (Const32 [c])) // result: (Const16 [int16(c)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(int16(c)) return true } // match: (Trunc32to16 (ZeroExt8to32 x)) // result: (ZeroExt8to16 x) for { if v_0.Op != OpZeroExt8to32 { break } x := v_0.Args[0] v.reset(OpZeroExt8to16) v.AddArg(x) return true } // match: (Trunc32to16 (ZeroExt16to32 x)) // result: x for { if v_0.Op != OpZeroExt16to32 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc32to16 (SignExt8to32 x)) // result: (SignExt8to16 x) for { if v_0.Op != OpSignExt8to32 { break } x := v_0.Args[0] v.reset(OpSignExt8to16) v.AddArg(x) return true } // match: (Trunc32to16 (SignExt16to32 x)) // result: x for { if v_0.Op != OpSignExt16to32 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc32to16 (And32 (Const32 [y]) x)) // cond: y&0xFFFF == 0xFFFF // result: (Trunc32to16 x) for { if v_0.Op != OpAnd32 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst32 { continue } y := auxIntToInt32(v_0_0.AuxInt) x := v_0_1 if !(y&0xFFFF == 0xFFFF) { continue } v.reset(OpTrunc32to16) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpTrunc32to8(v *Value) bool { v_0 := v.Args[0] // match: (Trunc32to8 (Const32 [c])) // result: (Const8 [int8(c)]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(int8(c)) return true } // match: (Trunc32to8 (ZeroExt8to32 x)) // result: x for { if v_0.Op != OpZeroExt8to32 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc32to8 (SignExt8to32 x)) // result: x for { if v_0.Op != OpSignExt8to32 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc32to8 (And32 (Const32 [y]) x)) // cond: y&0xFF == 0xFF // result: (Trunc32to8 x) for { if v_0.Op != OpAnd32 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst32 { continue } y := auxIntToInt32(v_0_0.AuxInt) x := v_0_1 if !(y&0xFF == 0xFF) { continue } v.reset(OpTrunc32to8) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpTrunc64to16(v *Value) bool { v_0 := v.Args[0] // match: (Trunc64to16 (Const64 [c])) // result: (Const16 [int16(c)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(int16(c)) return true } // match: (Trunc64to16 (ZeroExt8to64 x)) // result: (ZeroExt8to16 x) for { if v_0.Op != OpZeroExt8to64 { break } x := v_0.Args[0] v.reset(OpZeroExt8to16) v.AddArg(x) return true } // match: (Trunc64to16 (ZeroExt16to64 x)) // result: x for { if v_0.Op != OpZeroExt16to64 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc64to16 (SignExt8to64 x)) // result: (SignExt8to16 x) for { if v_0.Op != OpSignExt8to64 { break } x := v_0.Args[0] v.reset(OpSignExt8to16) v.AddArg(x) return true } // match: (Trunc64to16 (SignExt16to64 x)) // result: x for { if v_0.Op != OpSignExt16to64 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc64to16 (And64 (Const64 [y]) x)) // cond: y&0xFFFF == 0xFFFF // result: (Trunc64to16 x) for { if v_0.Op != OpAnd64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst64 { continue } y := auxIntToInt64(v_0_0.AuxInt) x := v_0_1 if !(y&0xFFFF == 0xFFFF) { continue } v.reset(OpTrunc64to16) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpTrunc64to32(v *Value) bool { v_0 := v.Args[0] // match: (Trunc64to32 (Const64 [c])) // result: (Const32 [int32(c)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(c)) return true } // match: (Trunc64to32 (ZeroExt8to64 x)) // result: (ZeroExt8to32 x) for { if v_0.Op != OpZeroExt8to64 { break } x := v_0.Args[0] v.reset(OpZeroExt8to32) v.AddArg(x) return true } // match: (Trunc64to32 (ZeroExt16to64 x)) // result: (ZeroExt16to32 x) for { if v_0.Op != OpZeroExt16to64 { break } x := v_0.Args[0] v.reset(OpZeroExt16to32) v.AddArg(x) return true } // match: (Trunc64to32 (ZeroExt32to64 x)) // result: x for { if v_0.Op != OpZeroExt32to64 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc64to32 (SignExt8to64 x)) // result: (SignExt8to32 x) for { if v_0.Op != OpSignExt8to64 { break } x := v_0.Args[0] v.reset(OpSignExt8to32) v.AddArg(x) return true } // match: (Trunc64to32 (SignExt16to64 x)) // result: (SignExt16to32 x) for { if v_0.Op != OpSignExt16to64 { break } x := v_0.Args[0] v.reset(OpSignExt16to32) v.AddArg(x) return true } // match: (Trunc64to32 (SignExt32to64 x)) // result: x for { if v_0.Op != OpSignExt32to64 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc64to32 (And64 (Const64 [y]) x)) // cond: y&0xFFFFFFFF == 0xFFFFFFFF // result: (Trunc64to32 x) for { if v_0.Op != OpAnd64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst64 { continue } y := auxIntToInt64(v_0_0.AuxInt) x := v_0_1 if !(y&0xFFFFFFFF == 0xFFFFFFFF) { continue } v.reset(OpTrunc64to32) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpTrunc64to8(v *Value) bool { v_0 := v.Args[0] // match: (Trunc64to8 (Const64 [c])) // result: (Const8 [int8(c)]) for { if v_0.Op != OpConst64 { break } c := auxIntToInt64(v_0.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(int8(c)) return true } // match: (Trunc64to8 (ZeroExt8to64 x)) // result: x for { if v_0.Op != OpZeroExt8to64 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc64to8 (SignExt8to64 x)) // result: x for { if v_0.Op != OpSignExt8to64 { break } x := v_0.Args[0] v.copyOf(x) return true } // match: (Trunc64to8 (And64 (Const64 [y]) x)) // cond: y&0xFF == 0xFF // result: (Trunc64to8 x) for { if v_0.Op != OpAnd64 { break } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i0 := 0; _i0 <= 1; _i0, v_0_0, v_0_1 = _i0+1, v_0_1, v_0_0 { if v_0_0.Op != OpConst64 { continue } y := auxIntToInt64(v_0_0.AuxInt) x := v_0_1 if !(y&0xFF == 0xFF) { continue } v.reset(OpTrunc64to8) v.AddArg(x) return true } break } return false } func rewriteValuegeneric_OpXor16(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Xor16 (Const16 [c]) (Const16 [d])) // result: (Const16 [c^d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpConst16 { continue } d := auxIntToInt16(v_1.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(c ^ d) return true } break } // match: (Xor16 x x) // result: (Const16 [0]) for { x := v_0 if x != v_1 { break } v.reset(OpConst16) v.AuxInt = int16ToAuxInt(0) return true } // match: (Xor16 (Const16 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 || auxIntToInt16(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Xor16 x (Xor16 x y)) // result: y for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpXor16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.copyOf(y) return true } } break } // match: (Xor16 (Xor16 i:(Const16 <t>) z) x) // cond: (z.Op != OpConst16 && x.Op != OpConst16) // result: (Xor16 i (Xor16 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpXor16 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst16 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst16 && x.Op != OpConst16) { continue } v.reset(OpXor16) v0 := b.NewValue0(v.Pos, OpXor16, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Xor16 (Const16 <t> [c]) (Xor16 (Const16 <t> [d]) x)) // result: (Xor16 (Const16 <t> [c^d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst16 { continue } t := v_0.Type c := auxIntToInt16(v_0.AuxInt) if v_1.Op != OpXor16 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst16 || v_1_0.Type != t { continue } d := auxIntToInt16(v_1_0.AuxInt) x := v_1_1 v.reset(OpXor16) v0 := b.NewValue0(v.Pos, OpConst16, t) v0.AuxInt = int16ToAuxInt(c ^ d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpXor32(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Xor32 (Const32 [c]) (Const32 [d])) // result: (Const32 [c^d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpConst32 { continue } d := auxIntToInt32(v_1.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(c ^ d) return true } break } // match: (Xor32 x x) // result: (Const32 [0]) for { x := v_0 if x != v_1 { break } v.reset(OpConst32) v.AuxInt = int32ToAuxInt(0) return true } // match: (Xor32 (Const32 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 || auxIntToInt32(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Xor32 x (Xor32 x y)) // result: y for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpXor32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.copyOf(y) return true } } break } // match: (Xor32 (Xor32 i:(Const32 <t>) z) x) // cond: (z.Op != OpConst32 && x.Op != OpConst32) // result: (Xor32 i (Xor32 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpXor32 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst32 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst32 && x.Op != OpConst32) { continue } v.reset(OpXor32) v0 := b.NewValue0(v.Pos, OpXor32, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Xor32 (Const32 <t> [c]) (Xor32 (Const32 <t> [d]) x)) // result: (Xor32 (Const32 <t> [c^d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst32 { continue } t := v_0.Type c := auxIntToInt32(v_0.AuxInt) if v_1.Op != OpXor32 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst32 || v_1_0.Type != t { continue } d := auxIntToInt32(v_1_0.AuxInt) x := v_1_1 v.reset(OpXor32) v0 := b.NewValue0(v.Pos, OpConst32, t) v0.AuxInt = int32ToAuxInt(c ^ d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpXor64(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Xor64 (Const64 [c]) (Const64 [d])) // result: (Const64 [c^d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpConst64 { continue } d := auxIntToInt64(v_1.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(c ^ d) return true } break } // match: (Xor64 x x) // result: (Const64 [0]) for { x := v_0 if x != v_1 { break } v.reset(OpConst64) v.AuxInt = int64ToAuxInt(0) return true } // match: (Xor64 (Const64 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 || auxIntToInt64(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Xor64 x (Xor64 x y)) // result: y for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpXor64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.copyOf(y) return true } } break } // match: (Xor64 (Xor64 i:(Const64 <t>) z) x) // cond: (z.Op != OpConst64 && x.Op != OpConst64) // result: (Xor64 i (Xor64 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpXor64 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst64 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst64 && x.Op != OpConst64) { continue } v.reset(OpXor64) v0 := b.NewValue0(v.Pos, OpXor64, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Xor64 (Const64 <t> [c]) (Xor64 (Const64 <t> [d]) x)) // result: (Xor64 (Const64 <t> [c^d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst64 { continue } t := v_0.Type c := auxIntToInt64(v_0.AuxInt) if v_1.Op != OpXor64 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst64 || v_1_0.Type != t { continue } d := auxIntToInt64(v_1_0.AuxInt) x := v_1_1 v.reset(OpXor64) v0 := b.NewValue0(v.Pos, OpConst64, t) v0.AuxInt = int64ToAuxInt(c ^ d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpXor8(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block // match: (Xor8 (Const8 [c]) (Const8 [d])) // result: (Const8 [c^d]) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpConst8 { continue } d := auxIntToInt8(v_1.AuxInt) v.reset(OpConst8) v.AuxInt = int8ToAuxInt(c ^ d) return true } break } // match: (Xor8 x x) // result: (Const8 [0]) for { x := v_0 if x != v_1 { break } v.reset(OpConst8) v.AuxInt = int8ToAuxInt(0) return true } // match: (Xor8 (Const8 [0]) x) // result: x for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 || auxIntToInt8(v_0.AuxInt) != 0 { continue } x := v_1 v.copyOf(x) return true } break } // match: (Xor8 x (Xor8 x y)) // result: y for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { x := v_0 if v_1.Op != OpXor8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if x != v_1_0 { continue } y := v_1_1 v.copyOf(y) return true } } break } // match: (Xor8 (Xor8 i:(Const8 <t>) z) x) // cond: (z.Op != OpConst8 && x.Op != OpConst8) // result: (Xor8 i (Xor8 <t> z x)) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpXor8 { continue } _ = v_0.Args[1] v_0_0 := v_0.Args[0] v_0_1 := v_0.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_0_0, v_0_1 = _i1+1, v_0_1, v_0_0 { i := v_0_0 if i.Op != OpConst8 { continue } t := i.Type z := v_0_1 x := v_1 if !(z.Op != OpConst8 && x.Op != OpConst8) { continue } v.reset(OpXor8) v0 := b.NewValue0(v.Pos, OpXor8, t) v0.AddArg2(z, x) v.AddArg2(i, v0) return true } } break } // match: (Xor8 (Const8 <t> [c]) (Xor8 (Const8 <t> [d]) x)) // result: (Xor8 (Const8 <t> [c^d]) x) for { for _i0 := 0; _i0 <= 1; _i0, v_0, v_1 = _i0+1, v_1, v_0 { if v_0.Op != OpConst8 { continue } t := v_0.Type c := auxIntToInt8(v_0.AuxInt) if v_1.Op != OpXor8 { continue } _ = v_1.Args[1] v_1_0 := v_1.Args[0] v_1_1 := v_1.Args[1] for _i1 := 0; _i1 <= 1; _i1, v_1_0, v_1_1 = _i1+1, v_1_1, v_1_0 { if v_1_0.Op != OpConst8 || v_1_0.Type != t { continue } d := auxIntToInt8(v_1_0.AuxInt) x := v_1_1 v.reset(OpXor8) v0 := b.NewValue0(v.Pos, OpConst8, t) v0.AuxInt = int8ToAuxInt(c ^ d) v.AddArg2(v0, x) return true } } break } return false } func rewriteValuegeneric_OpZero(v *Value) bool { v_1 := v.Args[1] v_0 := v.Args[0] b := v.Block config := b.Func.Config // match: (Zero (Load (OffPtr [c] (SP)) mem) mem) // cond: mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize() + config.RegSize // result: mem for { if v_0.Op != OpLoad { break } mem := v_0.Args[1] v_0_0 := v_0.Args[0] if v_0_0.Op != OpOffPtr { break } c := auxIntToInt64(v_0_0.AuxInt) v_0_0_0 := v_0_0.Args[0] if v_0_0_0.Op != OpSP || mem != v_1 || !(mem.Op == OpStaticCall && isSameSym(mem.Aux, "runtime.newobject") && c == config.ctxt.FixedFrameSize()+config.RegSize) { break } v.copyOf(mem) return true } // match: (Zero {t1} [n] p1 store:(Store {t2} (OffPtr [o2] p2) _ mem)) // cond: isSamePtr(p1, p2) && store.Uses == 1 && n >= o2 + t2.Size() && clobber(store) // result: (Zero {t1} [n] p1 mem) for { n := auxIntToInt64(v.AuxInt) t1 := auxToType(v.Aux) p1 := v_0 store := v_1 if store.Op != OpStore { break } t2 := auxToType(store.Aux) mem := store.Args[2] store_0 := store.Args[0] if store_0.Op != OpOffPtr { break } o2 := auxIntToInt64(store_0.AuxInt) p2 := store_0.Args[0] if !(isSamePtr(p1, p2) && store.Uses == 1 && n >= o2+t2.Size() && clobber(store)) { break } v.reset(OpZero) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t1) v.AddArg2(p1, mem) return true } // match: (Zero {t} [n] dst1 move:(Move {t} [n] dst2 _ mem)) // cond: move.Uses == 1 && isSamePtr(dst1, dst2) && clobber(move) // result: (Zero {t} [n] dst1 mem) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 move := v_1 if move.Op != OpMove || auxIntToInt64(move.AuxInt) != n || auxToType(move.Aux) != t { break } mem := move.Args[2] dst2 := move.Args[0] if !(move.Uses == 1 && isSamePtr(dst1, dst2) && clobber(move)) { break } v.reset(OpZero) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v.AddArg2(dst1, mem) return true } // match: (Zero {t} [n] dst1 vardef:(VarDef {x} move:(Move {t} [n] dst2 _ mem))) // cond: move.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && clobber(move, vardef) // result: (Zero {t} [n] dst1 (VarDef {x} mem)) for { n := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 vardef := v_1 if vardef.Op != OpVarDef { break } x := auxToSym(vardef.Aux) move := vardef.Args[0] if move.Op != OpMove || auxIntToInt64(move.AuxInt) != n || auxToType(move.Aux) != t { break } mem := move.Args[2] dst2 := move.Args[0] if !(move.Uses == 1 && vardef.Uses == 1 && isSamePtr(dst1, dst2) && clobber(move, vardef)) { break } v.reset(OpZero) v.AuxInt = int64ToAuxInt(n) v.Aux = typeToAux(t) v0 := b.NewValue0(v.Pos, OpVarDef, types.TypeMem) v0.Aux = symToAux(x) v0.AddArg(mem) v.AddArg2(dst1, v0) return true } // match: (Zero {t} [s] dst1 zero:(Zero {t} [s] dst2 _)) // cond: isSamePtr(dst1, dst2) // result: zero for { s := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 zero := v_1 if zero.Op != OpZero || auxIntToInt64(zero.AuxInt) != s || auxToType(zero.Aux) != t { break } dst2 := zero.Args[0] if !(isSamePtr(dst1, dst2)) { break } v.copyOf(zero) return true } // match: (Zero {t} [s] dst1 vardef:(VarDef (Zero {t} [s] dst2 _))) // cond: isSamePtr(dst1, dst2) // result: vardef for { s := auxIntToInt64(v.AuxInt) t := auxToType(v.Aux) dst1 := v_0 vardef := v_1 if vardef.Op != OpVarDef { break } vardef_0 := vardef.Args[0] if vardef_0.Op != OpZero || auxIntToInt64(vardef_0.AuxInt) != s || auxToType(vardef_0.Aux) != t { break } dst2 := vardef_0.Args[0] if !(isSamePtr(dst1, dst2)) { break } v.copyOf(vardef) return true } return false } func rewriteValuegeneric_OpZeroExt16to32(v *Value) bool { v_0 := v.Args[0] // match: (ZeroExt16to32 (Const16 [c])) // result: (Const32 [int32(uint16(c))]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(uint16(c))) return true } // match: (ZeroExt16to32 (Trunc32to16 x:(Rsh32Ux64 _ (Const64 [s])))) // cond: s >= 16 // result: x for { if v_0.Op != OpTrunc32to16 { break } x := v_0.Args[0] if x.Op != OpRsh32Ux64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 16) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpZeroExt16to64(v *Value) bool { v_0 := v.Args[0] // match: (ZeroExt16to64 (Const16 [c])) // result: (Const64 [int64(uint16(c))]) for { if v_0.Op != OpConst16 { break } c := auxIntToInt16(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(uint16(c))) return true } // match: (ZeroExt16to64 (Trunc64to16 x:(Rsh64Ux64 _ (Const64 [s])))) // cond: s >= 48 // result: x for { if v_0.Op != OpTrunc64to16 { break } x := v_0.Args[0] if x.Op != OpRsh64Ux64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 48) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpZeroExt32to64(v *Value) bool { v_0 := v.Args[0] // match: (ZeroExt32to64 (Const32 [c])) // result: (Const64 [int64(uint32(c))]) for { if v_0.Op != OpConst32 { break } c := auxIntToInt32(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(uint32(c))) return true } // match: (ZeroExt32to64 (Trunc64to32 x:(Rsh64Ux64 _ (Const64 [s])))) // cond: s >= 32 // result: x for { if v_0.Op != OpTrunc64to32 { break } x := v_0.Args[0] if x.Op != OpRsh64Ux64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 32) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpZeroExt8to16(v *Value) bool { v_0 := v.Args[0] // match: (ZeroExt8to16 (Const8 [c])) // result: (Const16 [int16( uint8(c))]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v.reset(OpConst16) v.AuxInt = int16ToAuxInt(int16(uint8(c))) return true } // match: (ZeroExt8to16 (Trunc16to8 x:(Rsh16Ux64 _ (Const64 [s])))) // cond: s >= 8 // result: x for { if v_0.Op != OpTrunc16to8 { break } x := v_0.Args[0] if x.Op != OpRsh16Ux64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 8) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpZeroExt8to32(v *Value) bool { v_0 := v.Args[0] // match: (ZeroExt8to32 (Const8 [c])) // result: (Const32 [int32( uint8(c))]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v.reset(OpConst32) v.AuxInt = int32ToAuxInt(int32(uint8(c))) return true } // match: (ZeroExt8to32 (Trunc32to8 x:(Rsh32Ux64 _ (Const64 [s])))) // cond: s >= 24 // result: x for { if v_0.Op != OpTrunc32to8 { break } x := v_0.Args[0] if x.Op != OpRsh32Ux64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 24) { break } v.copyOf(x) return true } return false } func rewriteValuegeneric_OpZeroExt8to64(v *Value) bool { v_0 := v.Args[0] // match: (ZeroExt8to64 (Const8 [c])) // result: (Const64 [int64( uint8(c))]) for { if v_0.Op != OpConst8 { break } c := auxIntToInt8(v_0.AuxInt) v.reset(OpConst64) v.AuxInt = int64ToAuxInt(int64(uint8(c))) return true } // match: (ZeroExt8to64 (Trunc64to8 x:(Rsh64Ux64 _ (Const64 [s])))) // cond: s >= 56 // result: x for { if v_0.Op != OpTrunc64to8 { break } x := v_0.Args[0] if x.Op != OpRsh64Ux64 { break } _ = x.Args[1] x_1 := x.Args[1] if x_1.Op != OpConst64 { break } s := auxIntToInt64(x_1.AuxInt) if !(s >= 56) { break } v.copyOf(x) return true } return false } func rewriteBlockgeneric(b *Block) bool { switch b.Kind { case BlockIf: // match: (If (Not cond) yes no) // result: (If cond no yes) for b.Controls[0].Op == OpNot { v_0 := b.Controls[0] cond := v_0.Args[0] b.resetWithControl(BlockIf, cond) b.swapSuccessors() return true } // match: (If (ConstBool [c]) yes no) // cond: c // result: (First yes no) for b.Controls[0].Op == OpConstBool { v_0 := b.Controls[0] c := auxIntToBool(v_0.AuxInt) if !(c) { break } b.Reset(BlockFirst) return true } // match: (If (ConstBool [c]) yes no) // cond: !c // result: (First no yes) for b.Controls[0].Op == OpConstBool { v_0 := b.Controls[0] c := auxIntToBool(v_0.AuxInt) if !(!c) { break } b.Reset(BlockFirst) b.swapSuccessors() return true } } return false }
bsd-3-clause
NCIP/cadsr-cgmdr-nci-uk
test/src/org/exist/xmldb/StorageStressTest.java
6249
/*L * Copyright Oracle Inc * * Distributed under the OSI-approved BSD 3-Clause License. * See http://ncip.github.com/cadsr-cgmdr-nci-uk/LICENSE.txt for details. */ /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 The eXist Project * http://exist-db.org * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id$ */ package org.exist.xmldb; import java.io.File; import java.net.BindException; import java.util.Iterator; import junit.framework.TestCase; import junit.textui.TestRunner; import org.exist.storage.DBBroker; import org.exist.StandaloneServer; import org.exist.xmldb.concurrent.DBUtils; import org.mortbay.util.MultiException; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; import org.xmldb.api.base.Database; import org.xmldb.api.base.Resource; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.CollectionManagementService; import org.xmldb.api.modules.XMLResource; /** * @author ??? * @author Pierrick Brihaye <[email protected]> */ public class StorageStressTest extends TestCase { private static StandaloneServer server = null; //TODO : why a remote test ? protected final static String URI = "xmldb:exist://localhost:8088/xmlrpc"; //protected final static String URI = "xmldb:exist://"; public final static String DB_DRIVER = "org.exist.xmldb.DatabaseImpl"; private final static String COLLECTION_NAME = "unit-testing-collection"; private final static String CONFIG = "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" + " <index xmlns:x=\"http://www.foo.com\" xmlns:xx=\"http://test.com\">" + " <fulltext default=\"all\" attributes=\"true\">" + " </fulltext>" + " <create path=\"//ELEMENT-1/@attribute-1\" type=\"xs:string\"/>" + " </index>" + "</collection>"; private Collection collection = null; public void testStore() { try { String[] wordList = DBUtils.wordList(collection); long start = System.currentTimeMillis(); for (int i = 0; i < 30000; i++) { File f = DBUtils.generateXMLFile(6, 3, wordList, false); System.out.println("Storing file: " + f.getName() + "; size: " + (f.length() / 1024) + "kB"); Resource res = collection.createResource("test_" + i, "XMLResource"); res.setContent(f); collection.storeResource(res); f.delete(); } System.out.println("Indexing took " + (System.currentTimeMillis() - start)); } catch (Exception e) { fail(e.getMessage()); } } protected void setUp() { //Don't worry about closing the server : the shutdown hook will do the job initServer(); setUpRemoteDatabase(); } private void initServer() { try { if (server == null) { server = new StandaloneServer(); if (!server.isStarted()) { try { System.out.println("Starting standalone server..."); String[] args = {}; server.run(args); while (!server.isStarted()) { Thread.sleep(1000); } } catch (MultiException e) { boolean rethrow = true; Iterator i = e.getExceptions().iterator(); while (i.hasNext()) { Exception e0 = (Exception)i.next(); if (e0 instanceof BindException) { System.out.println("A server is running already !"); rethrow = false; break; } } if (rethrow) throw e; } } } } catch (Exception e) { fail(e.getMessage()); } } protected void setUpRemoteDatabase() { try { Class cl = Class.forName(DB_DRIVER); Database database = (Database) cl.newInstance(); database.setProperty("create-database", "true"); DatabaseManager.registerDatabase(database); Collection rootCollection = DatabaseManager.getCollection(URI + DBBroker.ROOT_COLLECTION, "admin", null); Collection childCollection = rootCollection.getChildCollection(COLLECTION_NAME); if (childCollection == null) { CollectionManagementService cms = (CollectionManagementService) rootCollection.getService( "CollectionManagementService", "1.0"); this.collection = cms.createCollection(COLLECTION_NAME); } else { this.collection = childCollection; } String existHome = System.getProperty("exist.home"); File existDir = existHome==null ? new File(".") : new File(existHome); File f = new File(existDir,"samples/shakespeare/hamlet.xml"); Resource res = collection.createResource("test1.xml", "XMLResource"); res.setContent(f); collection.storeResource(res); IndexQueryService idxConf = (IndexQueryService) collection.getService("IndexQueryService", "1.0"); // idxConf.configureCollection(CONFIG); } catch (Exception e) { fail(e.getMessage()); } } public static void main(String[] args) { TestRunner.run(StorageStressTest.class); //Explicit shutdown for the shutdown hook System.exit(0); } }
bsd-3-clause
sergeyreznik/et-engine
include/et/rendering/vulkan/vulkan_renderer.cpp
22196
/* * This file is part of `et engine` * Copyright 2009-2016 by Sergey Reznik * Please, modify content only if you know what are you doing. * */ #pragma once #include <et/rendering/vulkan/vulkan_buffer.h> #include <et/rendering/vulkan/vulkan_compute.h> #include <et/rendering/vulkan/vulkan_program.h> #include <et/rendering/vulkan/vulkan_texture.h> #include <et/rendering/vulkan/vulkan_sampler.h> #include <et/rendering/vulkan/vulkan_renderpass.h> #include <et/rendering/vulkan/vulkan_textureset.h> #include <et/rendering/vulkan/vulkan_pipelinestate.h> #include <et/rendering/vulkan/vulkan_renderer.h> #include <et/rendering/vulkan/vulkan.h> #include <et/rendering/vulkan/glslang/vulkan_glslang.h> #include <et/app/application.h> namespace et { class VulkanRendererPrivate : public VulkanState { public: VulkanState & vulkan() { return *this; } struct FrameInternal : public Shared { ET_DECLARE_POINTER(FrameInternal); RendererFrame frame; Vector<VulkanRenderPass::Pointer> passes; }; PipelineStateCache pipelineCache; std::mutex framesMutex; Vector<FrameInternal::Pointer> framesQueue; Vector<FrameInternal::Pointer> framesCache; FrameInternal::Pointer buildingFrame; Vector<VkSubmitInfo> allSubmits; Vector<VkSemaphore> waitSemaphores; Vector<VkSemaphore> signalSemaphores; Vector<VkPipelineStageFlags> waitStages; Vector<VkCommandBuffer> commandBuffers; uint64_t continuousFrameNumber = 0; void presentFrame(VulkanRenderer* renderer, FrameInternal::Pointer&); }; VulkanRenderer::VulkanRenderer() { ET_PIMPL_INIT(VulkanRenderer); Camera::renderingOriginTransform = -1.0f; Camera::zeroClipRange = true; } VulkanRenderer::~VulkanRenderer() { ET_PIMPL_FINALIZE(VulkanRenderer); } VkResult vkEnumerateInstanceLayerPropertiesWrapper(int, uint32_t* count, VkLayerProperties* props) { return vkEnumerateInstanceLayerProperties(count, props); } VkResult vkEnumerateDeviceExtensionPropertiesWrapper(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkExtensionProperties* pProperties) { return vkEnumerateDeviceExtensionProperties(physicalDevice, nullptr, pPropertyCount, pProperties); } VkBool32 VKAPI_CALL vulkanDebugCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t obj, size_t location, int32_t code, const char* layerPrefix, const char* msg, void* userData) { if (obj == static_cast<uint64_t>(-1)) obj = 0; if (flags & VK_DEBUG_REPORT_ERROR_BIT_EXT) { log::error("%s [%llx] : %s", layerPrefix, obj, msg); debug::debugBreak(); } else if (flags & VK_DEBUG_REPORT_WARNING_BIT_EXT) { log::warning("%s [%llx] : %s", layerPrefix, obj, msg); } else { log::info("%s [%llx] : %s", layerPrefix, obj, msg); } return VK_FALSE; } void VulkanRenderer::init(const RenderContextParameters& params) { _parameters = params; initGlslangResources(); Vector<const char*> validationLayers; #if (ET_VULKAN_ENABLE_VALIDATION) auto layerProps = enumerateVulkanObjects<VkLayerProperties>(0, vkEnumerateInstanceLayerPropertiesWrapper); validationLayers.reserve(4); for (const VkLayerProperties& layerProp : layerProps) { if (strstr(layerProp.layerName, "validation") || strstr(layerProp.layerName, "thread")) { validationLayers.emplace_back(layerProp.layerName); log::info("Vulkan validation layer used: %s (%s)", layerProp.layerName, layerProp.description); } } #endif VkApplicationInfo appInfo = { VK_STRUCTURE_TYPE_APPLICATION_INFO }; appInfo.pApplicationName = application().identifier().applicationName.c_str(); appInfo.pEngineName = "et-engine"; appInfo.apiVersion = VK_API_VERSION_1_0; std::vector<const char*> instanceExtensions = { VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME, # if (ET_VULKAN_ENABLE_VALIDATION) VK_EXT_DEBUG_REPORT_EXTENSION_NAME, # endif }; VkInstanceCreateInfo instanceCreateInfo = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO }; instanceCreateInfo.pApplicationInfo = &appInfo; instanceCreateInfo.enabledExtensionCount = static_cast<uint32_t>(instanceExtensions.size()); instanceCreateInfo.ppEnabledExtensionNames = instanceExtensions.data(); instanceCreateInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size()); instanceCreateInfo.ppEnabledLayerNames = validationLayers.data(); VULKAN_CALL(vkCreateInstance(&instanceCreateInfo, nullptr, &_private->instance)); #if (ET_VULKAN_ENABLE_VALIDATION) PFN_vkCreateDebugReportCallbackEXT createDebugCb = reinterpret_cast<PFN_vkCreateDebugReportCallbackEXT>(vkGetInstanceProcAddr(_private->instance, "vkCreateDebugReportCallbackEXT")); if (createDebugCb) { VkDebugReportCallbackCreateInfoEXT debugInfo = { VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT }; debugInfo.flags = VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_ERROR_BIT_EXT; debugInfo.pfnCallback = reinterpret_cast<PFN_vkDebugReportCallbackEXT>(vulkanDebugCallback); VULKAN_CALL(createDebugCb(_private->instance, &debugInfo, nullptr, &_private->debugCallback)); } #endif auto physicalDevices = enumerateVulkanObjects<VkPhysicalDevice>(_private->instance, vkEnumeratePhysicalDevices); ET_ASSERT(!physicalDevices.empty()); _private->physicalDevice = physicalDevices.front(); vkGetPhysicalDeviceProperties(_private->physicalDevice, &_private->physicalDeviceProperties); vkGetPhysicalDeviceFeatures(_private->physicalDevice, &_private->physicalDeviceFeatures); Vector<VkQueueFamilyProperties> queueProperties = enumerateVulkanObjects<VkQueueFamilyProperties>(_private->physicalDevice, vkGetPhysicalDeviceQueueFamilyProperties); ET_ASSERT(queueProperties.size() > 0); VkDeviceQueueCreateInfo queueCreateInfos[VulkanQueueClass_Count] = { { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO }, { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO } }; uint32_t queuesIndex = 0; float queuePriorities[] = { 0.0f }; for (const VkQueueFamilyProperties& props : queueProperties) { if (props.queueFlags & VK_QUEUE_GRAPHICS_BIT && (_private->queues[VulkanQueueClass::Graphics].index == static_cast<uint32_t>(-1))) { _private->queues[VulkanQueueClass::Graphics].index = queuesIndex; queueCreateInfos[VulkanQueueClass::Graphics].queueFamilyIndex = queuesIndex; queueCreateInfos[VulkanQueueClass::Graphics].queueCount = 1; queueCreateInfos[VulkanQueueClass::Graphics].pQueuePriorities = queuePriorities; _private->queues[VulkanQueueClass::Graphics].properties = props; } if ((props.queueFlags & VK_QUEUE_COMPUTE_BIT) && (_private->queues[VulkanQueueClass::Compute].index == static_cast<uint32_t>(-1))) { _private->queues[VulkanQueueClass::Compute].index = queuesIndex; queueCreateInfos[VulkanQueueClass::Compute].queueFamilyIndex = queuesIndex; queueCreateInfos[VulkanQueueClass::Compute].queueCount = 1; queueCreateInfos[VulkanQueueClass::Compute].pQueuePriorities = queuePriorities; _private->queues[VulkanQueueClass::Compute].properties = props; } ++queuesIndex; } bool computeAndGraphicsIsTheSame = (_private->queues[VulkanQueueClass::Compute].index == _private->queues[VulkanQueueClass::Graphics].index);; uint32_t totalQueuesCount = computeAndGraphicsIsTheSame ? 1 : queuesIndex; Vector<VkExtensionProperties> availableExtensions = enumerateVulkanObjects<VkExtensionProperties>(_private->physicalDevice, vkEnumerateDeviceExtensionPropertiesWrapper); bool hasDebugMarker = std::find_if(std::begin(availableExtensions), std::end(availableExtensions), [](const VkExtensionProperties& i) { return (strcmp(i.extensionName, VK_EXT_DEBUG_MARKER_EXTENSION_NAME) == 0); }) != std::end(availableExtensions); Vector<const char*> deviceExtensions = { VK_KHR_SWAPCHAIN_EXTENSION_NAME }; if (hasDebugMarker) { deviceExtensions.emplace_back(VK_EXT_DEBUG_MARKER_EXTENSION_NAME); } VkPhysicalDeviceFeatures deviceFeatures = { }; deviceFeatures.samplerAnisotropy = VK_TRUE; deviceFeatures.textureCompressionBC = VK_TRUE; VkDeviceCreateInfo deviceCreateInfo = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO }; deviceCreateInfo.queueCreateInfoCount = totalQueuesCount; deviceCreateInfo.pQueueCreateInfos = queueCreateInfos; deviceCreateInfo.enabledExtensionCount = static_cast<uint32_t>(deviceExtensions.size()); deviceCreateInfo.ppEnabledExtensionNames = deviceExtensions.data(); deviceCreateInfo.pEnabledFeatures = &deviceFeatures; VULKAN_CALL(vkCreateDevice(_private->physicalDevice, &deviceCreateInfo, nullptr, &_private->device)); for (uint32_t i = 0; i < totalQueuesCount; ++i) { VulkanQueue& queue = _private->queues[i]; vkGetDeviceQueue(_private->device, queue.index, 0, &queue.queue); VkCommandPoolCreateInfo cmdPoolCreateInfo = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }; cmdPoolCreateInfo.queueFamilyIndex = queue.index; cmdPoolCreateInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; VULKAN_CALL(vkCreateCommandPool(_private->device, &cmdPoolCreateInfo, nullptr, &queue.commandPool)); VkCommandBufferAllocateInfo serviceBufferInfo = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO }; serviceBufferInfo.commandPool = queue.commandPool; serviceBufferInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; serviceBufferInfo.commandBufferCount = 1; VULKAN_CALL(vkAllocateCommandBuffers(_private->device, &serviceBufferInfo, &queue.serviceCommandBuffer)); } if (computeAndGraphicsIsTheSame) { _private->queues[VulkanQueueClass::Compute] = _private->queues[VulkanQueueClass::Graphics]; } _private->graphicsCommandPool = _private->queues[VulkanQueueClass::Graphics].commandPool; _private->computeCommandPool = _private->queues[VulkanQueueClass::Compute].commandPool; HWND mainWindow = reinterpret_cast<HWND>(application().context().objects[0]); _private->allocator.init(_private->vulkan()); _private->swapchain.init(_private->vulkan(), params, mainWindow); uint32_t defaultPoolSize = 8192; VkDescriptorPoolSize poolSizes[] = { { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC, defaultPoolSize }, { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, defaultPoolSize }, { VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, defaultPoolSize }, { VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, defaultPoolSize }, { VK_DESCRIPTOR_TYPE_SAMPLER, defaultPoolSize }, }; VkDescriptorPoolCreateInfo poolInfo = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; poolInfo.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT; poolInfo.maxSets = defaultPoolSize; poolInfo.poolSizeCount = sizeof(poolSizes) / sizeof(poolSizes[0]); poolInfo.pPoolSizes = poolSizes; VULKAN_CALL(vkCreateDescriptorPool(_private->device, &poolInfo, nullptr, &_private->descriptorPool)); RECT clientRect = { }; GetClientRect(mainWindow, &clientRect); resize(vec2i(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top)); for (uint32_t i = 0; i < RendererFrameCount; ++i) _private->framesCache.emplace_back(VulkanRendererPrivate::FrameInternal::Pointer::create()); initInternalStructures(); } void VulkanRenderer::shutdown() { VULKAN_CALL(vkDeviceWaitIdle(_private->device)); _private->framesQueue.clear(); _private->framesCache.clear(); _private->buildingFrame.reset(nullptr); VULKAN_CALL(vkDeviceWaitIdle(_private->device)); } void VulkanRenderer::destroy() { _private->pipelineCache.clear(); shutdownInternalStructures(); vkDestroyDescriptorPool(_private->device, _private->descriptorPool, nullptr); // TODO : clean up Vulkan cleanupGlslangResources(); } void VulkanRenderer::resize(const vec2i& sz) { _private->swapchain.createSizeDependentResources(_private->vulkan(), sz); } vec2i VulkanRenderer::contextSize() const { return vec2i(static_cast<int32_t>(_private->swapchain.extent.width), static_cast<int32_t>(_private->swapchain.extent.height)); } Buffer::Pointer VulkanRenderer::createBuffer(const std::string&, const Buffer::Description& desc) { return VulkanBuffer::Pointer::create(_private->vulkan(), desc); } Texture::Pointer VulkanRenderer::createTexture(const TextureDescription::Pointer& desc) { return VulkanTexture::Pointer::create(_private->vulkan(), desc.reference(), desc->data); } TextureSet::Pointer VulkanRenderer::createTextureSet(const TextureSet::Description& desc) { TextureSet::Pointer result; bool hasObjects = false; for (const auto& e : desc) { hasObjects |= e.second.allowEmptySet; hasObjects |= !e.second.images.empty(); hasObjects |= !e.second.textures.empty(); hasObjects |= !e.second.samplers.empty(); } return hasObjects ? VulkanTextureSet::Pointer::create(this, _private->vulkan(), desc) : emptyTextureBindingsSet(); } Sampler::Pointer VulkanRenderer::createSampler(const Sampler::Description& desc) { return VulkanSampler::Pointer::create(_private->vulkan(), desc); } Program::Pointer VulkanRenderer::createProgram(uint32_t stages, const std::string& source) { VulkanProgram::Pointer program = VulkanProgram::Pointer::create(_private->vulkan()); program->build(stages, source); return program; } PipelineState::Pointer VulkanRenderer::acquireGraphicsPipeline(const RenderPass::Pointer& pass, const Material::Pointer& mat, const VertexStream::Pointer& vs) { ET_ASSERT(mat->pipelineClass() == PipelineClass::Graphics); ET_ASSERT(mat->isInstance() == false); const std::string& cls = pass->info().name; const Material::Configuration& config = mat->configuration(cls); VulkanPipelineState::Pointer ps = _private->pipelineCache.find(pass->identifier(), vs->vertexDeclaration(), config.program, config.depthState, config.blendState, config.cullMode, vs->primitiveType()); if (ps.invalid()) { ps = VulkanPipelineState::Pointer::create(this, _private->vulkan()); ps->setPrimitiveType(vs->primitiveType()); ps->setInputLayout(vs->vertexDeclaration()); ps->setDepthState(config.depthState); ps->setBlendState(config.blendState); ps->setCullMode(config.cullMode); ps->setProgram(config.program); ps->build(pass); _private->pipelineCache.addToCache(pass, ps); } return ps; } Compute::Pointer VulkanRenderer::createCompute(const Material::Pointer& mtl) { return VulkanCompute::Pointer::create(_private->vulkan(), mtl); } RenderPass::Pointer VulkanRenderer::allocateRenderPass(const RenderPass::ConstructionInfo& info) { return VulkanRenderPass::Pointer::create(this, _private->vulkan(), info); } RendererFrame VulkanRenderer::allocateFrame() { ET_ASSERT(_private->buildingFrame.invalid()); while (_private->framesCache.empty()) threading::sleepMSec(0); { std::unique_lock<std::mutex> lock(_private->framesMutex); _private->buildingFrame = _private->framesCache.back(); _private->framesCache.pop_back(); } _private->buildingFrame->frame.continuousNumber = _private->continuousFrameNumber++; _private->buildingFrame->frame.identifier = _private->buildingFrame->frame.continuousNumber ^ uint64_t(reinterpret_cast<uintptr_t>(this)); uint64_t frameIndex = _private->buildingFrame->frame.index(); VulkanSwapchain::SwapchainFrame& swapchainFrame = _private->swapchain.mutableFrame(frameIndex); // VulkanSwapchain::SwapchainFrame& swapchainFrame = swapchain.mutableFrame(frame->frame.index()); _private->swapchain.acquireFrameImage(swapchainFrame, _private->vulkan()); if (swapchainFrame.timestampIndex > 0) { uint64_t timestampData[1024] = {}; VULKAN_CALL(vkGetQueryPoolResults(_private->vulkan().device, swapchainFrame.timestampsQueryPool, 0, swapchainFrame.timestampIndex, sizeof(timestampData), timestampData, sizeof(uint64_t), VK_QUERY_RESULT_64_BIT | VK_QUERY_RESULT_WAIT_BIT)); _statistics = {}; for (VulkanRenderPass::Pointer& pass : _private->buildingFrame->passes) { if (pass->fillStatistics(frameIndex, timestampData, _statistics.passes[_statistics.activeRenderPasses])) { ++_statistics.activeRenderPasses; } } swapchainFrame.timestampIndex = 0; } _private->buildingFrame->passes.clear(); return _private->buildingFrame->frame; } void VulkanRenderer::submitFrame(const RendererFrame& frame) { ET_ASSERT(_private->buildingFrame.valid()); ET_ASSERT(_private->buildingFrame->frame.identifier == frame.identifier); { std::unique_lock<std::mutex> lock(_private->framesMutex); _private->framesQueue.emplace_back(_private->buildingFrame); _private->buildingFrame.reset(nullptr); } } void VulkanRenderer::present() { VulkanRendererPrivate::FrameInternal::Pointer frameToExecute; { std::unique_lock<std::mutex> lock(_private->framesMutex); if (_private->framesQueue.empty() == false) { frameToExecute = _private->framesQueue.front(); _private->framesQueue.erase(_private->framesQueue.begin()); } } if (frameToExecute.valid()) { _private->presentFrame(this, frameToExecute); { std::unique_lock<std::mutex> lock(_private->framesMutex); _private->framesCache.insert(_private->framesCache.begin(), frameToExecute); } } } void VulkanRenderer::beginRenderPass(const RenderPass::Pointer& p, const RenderPassBeginInfo& info) { ET_ASSERT(_private->buildingFrame.valid()); VulkanRenderPass::Pointer pass = p; pass->begin(_private->buildingFrame->frame, info); } void VulkanRenderer::submitRenderPass(const RenderPass::Pointer& inPass) { ET_ASSERT(_private->buildingFrame.valid()); VulkanRenderPass::Pointer pass = inPass; pass->end(_private->buildingFrame->frame); _private->buildingFrame->passes.emplace_back(pass); } void VulkanRendererPrivate::presentFrame(VulkanRenderer* renderer, FrameInternal::Pointer& frame) { static VkPipelineStageFlags firstWaitStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT; static VkPipelineStageFlags lastWaitStage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT; VulkanSwapchain::SwapchainFrame& swapchainFrame = swapchain.mutableFrame(frame->frame.index()); Vector<VulkanRenderPass::Pointer>& passes = frame->passes; std::stable_sort(passes.begin(), passes.end(), [](const VulkanRenderPass::Pointer& l, const VulkanRenderPass::Pointer& r) { return l->info().priority > r->info().priority; }); renderer->sharedConstantBuffer().flush(frame->frame.continuousNumber); size_t maxQueueSize = 2 * (1 + std::min(32ull, sqr(passes.size()))); allSubmits.clear(); allSubmits.reserve(maxQueueSize); commandBuffers.clear(); commandBuffers.reserve(maxQueueSize); waitStages.clear(); waitStages.reserve(maxQueueSize); waitSemaphores.clear(); waitSemaphores.reserve(maxQueueSize); signalSemaphores.clear(); signalSemaphores.reserve(maxQueueSize); { allSubmits.emplace_back(); VkSubmitInfo& submitInfo = allSubmits.back(); submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &swapchainFrame.barrierFromPresent; submitInfo.waitSemaphoreCount = 1; submitInfo.pWaitSemaphores = &swapchainFrame.imageAcquired; submitInfo.pWaitDstStageMask = &firstWaitStage; submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &swapchainFrame.semaphoreFromPresent; } uint32_t commandBuffersBegin = 0; uint32_t waitBegin = 0; uint32_t signalBegin = 0; uint32_t submittedCommandBuffers = 0; uint32_t submittedWait = 0; uint32_t submittedSignal = 0; for (auto i = passes.begin(), e = passes.end(); i != e; ++i) { uint32_t commandBuffersEnd = commandBuffersBegin; uint32_t waitEnd = waitBegin; uint32_t signalEnd = signalBegin; if (i == passes.begin()) { waitSemaphores.emplace_back(swapchainFrame.semaphoreFromPresent); waitStages.emplace_back(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT); ++waitEnd; } for (auto si = signalSemaphores.begin() + signalBegin - submittedSignal, se = signalSemaphores.end(); si != se; ++si) { waitSemaphores.emplace_back(*si); waitStages.emplace_back(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); ++waitEnd; } const VulkanRenderPass::Pointer& passI = *i; signalSemaphores.emplace_back(passI->nativeRenderPassContent().semaphore); commandBuffers.emplace_back(passI->nativeRenderPassContent().commandBuffer); ++commandBuffersEnd; ++signalEnd; for (auto j = i + 1; (j != e) && ((*j)->info().priority == (*i)->info().priority); ++j, ++i) { const VulkanRenderPass::Pointer& passJ = *j; commandBuffers.emplace_back(passJ->nativeRenderPassContent().commandBuffer); signalSemaphores.emplace_back(passJ->nativeRenderPassContent().semaphore); ++commandBuffersEnd; ++signalEnd; } if (i + 1 == e) { signalSemaphores.emplace_back(swapchainFrame.semaphoreToPresent); signalBegin = static_cast<uint32_t>(signalSemaphores.size()) - 1; signalEnd = signalBegin + 1; } submittedCommandBuffers = commandBuffersEnd - commandBuffersBegin; submittedSignal = signalEnd - signalBegin; submittedWait = waitEnd - waitBegin; allSubmits.emplace_back(); VkSubmitInfo& submitInfo = allSubmits.back(); submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.pCommandBuffers = commandBuffers.data() + commandBuffersBegin; submitInfo.commandBufferCount = submittedCommandBuffers; ET_ASSERT(submitInfo.commandBufferCount > 0); submitInfo.pSignalSemaphores = signalSemaphores.data() + signalBegin; submitInfo.signalSemaphoreCount = submittedSignal; ET_ASSERT(submitInfo.signalSemaphoreCount > 0); submitInfo.pWaitDstStageMask = waitStages.data() + waitBegin; submitInfo.pWaitSemaphores = waitSemaphores.data() + waitBegin; submitInfo.waitSemaphoreCount = submittedWait; ET_ASSERT(submitInfo.waitSemaphoreCount > 0); commandBuffersBegin = commandBuffersEnd; signalBegin = signalEnd; waitBegin = waitEnd; } { allSubmits.emplace_back(); VkSubmitInfo& submitInfo = allSubmits.back(); submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.commandBufferCount = 1; submitInfo.pCommandBuffers = &swapchainFrame.barrierToPresent; submitInfo.waitSemaphoreCount = 1; submitInfo.pWaitSemaphores = passes.empty() ? &swapchainFrame.semaphoreFromPresent : &swapchainFrame.semaphoreToPresent; submitInfo.pWaitDstStageMask = &lastWaitStage; submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &swapchainFrame.submitCompleted; } VULKAN_CALL(vkQueueSubmit(queues[VulkanQueueClass::Graphics].queue, static_cast<uint32_t>(allSubmits.size()), allSubmits.data(), swapchainFrame.imageFence)); allSubmits.clear(); swapchain.present(swapchainFrame, *this); } }
bsd-3-clause
fake-name/ReadableWebProxy
WebMirror/management/rss_parser_funcs/feed_parse_extractFullybookedtranslationsWordpressCom.py
586
def extractFullybookedtranslationsWordpressCom(item): ''' Parser for 'fullybookedtranslations.wordpress.com' ''' vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title']) if not (chp or vol) or "preview" in item['title'].lower(): return None tagmap = [ ('PRC', 'PRC', 'translated'), ('Loiterous', 'Loiterous', 'oel'), ] for tagname, name, tl_type in tagmap: if tagname in item['tags']: return buildReleaseMessageWithType(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type) return False
bsd-3-clause
palfrey/twfy
scripts/update-hansard-all.pl
1432
#! /usr/bin/perl -w # vim:sw=8:ts=8:et:nowrap use strict; use FindBin; chdir $FindBin::Bin; use lib "$FindBin::Bin"; use lib "$FindBin::Bin/../../perllib"; use mySociety::Config; mySociety::Config::set_file('../conf/general'); use DBI; my $dsn = 'DBI:mysql:database=' . mySociety::Config::get('DB_NAME'). ':host=' . mySociety::Config::get('DB_HOST'); my $dbh = DBI->connect($dsn, mySociety::Config::get('DB_USER'), mySociety::Config::get('DB_PASS'), { RaiseError => 1, PrintError => 0 }); my $sthC = $dbh->prepare("select atime from video_timestamps where user_id=-1 and gid=?"); my $sthI = $dbh->prepare("insert into video_timestamps (user_id, atime, gid) values (-1, ?, ?) on duplicate key update atime=VALUES(atime)"); my $sthH = $dbh->prepare('update hansard set video_status = video_status | 2 where gid = ?'); for my $file (sort </home/twfy-live/hansard-updates/h*>) { open FP, $file; while (<FP>) { chomp; next if /^--/; my ($gid, $time) = split /\t/; next unless $time; my $atime = $dbh->selectrow_array($sthC, {}, "uk.org.publicwhip/debate/$gid"); if (!$atime || $atime ne $time) { $sthI->execute($time, "uk.org.publicwhip/debate/$gid"); $sthH->execute("uk.org.publicwhip/debate/$gid"); } } close FP; } $dbh->disconnect();
bsd-3-clause
Garethp/php-ews
src/API/Enumeration/SubscriptionStatusFrequencyType.php
258
<?php namespace garethp\ews\API\Enumeration; use garethp\ews\API\Enumeration; /** * Class representing SubscriptionStatusFrequencyType * * * XSD Type: SubscriptionStatusFrequencyType */ class SubscriptionStatusFrequencyType extends Enumeration { }
bsd-3-clause
myjfm/uranium
src/server/uranium_schema_service_impl.h
1055
// Copyright (c) 2016, myjfm([email protected]). All rights reserved. // This source code is licensed under the BSD-style license found in the // LICENSE file in the root directory of this source tree. // #ifndef URANIUM_SERVER_URANIUM_SCHEMA_SERVICE_IMPL_H_ #define URANIUM_SERVER_URANIUM_SCHEMA_SERVICE_IMPL_H_ #include <memory> #include "common/status.h" #include "network/cpp/uranium.grpc.pb.h" namespace uranium { class TableManager; class UraniumSchemaServiceImpl : public api::UraniumSchemaService::Service { public: UraniumSchemaServiceImpl() {} virtual ~UraniumSchemaServiceImpl() {} UraniumSchemaServiceImpl(const UraniumSchemaServiceImpl&) = delete; UraniumSchemaServiceImpl& operator=(UraniumSchemaServiceImpl&) = delete; Status Init(std::shared_ptr<TableManager> table_manager) { assert(table_manager.get()); table_manager_ = table_manager; return Status::OK(); } private: std::shared_ptr<TableManager> table_manager_; }; } // namespace uranium #endif // URANIUM_SERVER_URANIUM_SERVICE_IMPL_H_
bsd-3-clause
hahalulu/yii
demo/protected/views/admin/adminarticle/index.php
7002
<script type="text/javascript"></script> <div class="content-box"> <div class="content-box-header"> <h3 id="title" style="cursor: s-resize;">List Article</h3> <ul class="content-box-tabs"> <li><a href="#tab1" id="clickTab1" class="default-tab current">List Article</a></li> <!-- href must be unique and match the id of target div --> <li><a href="#tab2" id="clickTab2">Create New Article</a></li> </ul> <div class="clear"></div> </div> <div class="content-box-content"> <div class="tab-content default-tab" id="tab1" style="display: block;"> <!-- This is the target div. id must match the href of this div's tab --> <div class="notification attention png_bg"> <a href="#" class="close"><img src="<?php echo Yii::app()->request->baseUrl; ?>/css/admin/images/icons/cross_grey_small.png" title="Close this notification" alt="close"></a> <div> This is a Content Box. You can put whatever you want in it. By the way, you can close this notification with the top-right cross. </div> </div> <table> <thead> <tr> <th><input class="check-all" type="checkbox"></th> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> <th>Column 4</th> <th>Column 5</th> </tr> </thead> <tfoot> <tr> <td colspan="6"> <div class="bulk-actions align-left"> <select name="dropdown"> <option value="option1">Choose an action...</option> <option value="option2">Edit</option> <option value="option3">Delete</option> </select> <a class="button" href="#">Apply to selected</a> </div> <div class="pagination"> <a href="#" title="First Page"> << First</a><a href="#" title="Previous Page">< Previous</a> <a href="#" class="number" title="1">1</a> <a href="#" class="number" title="2">2</a> <a href="#" class="number current" title="3">3</a> <a href="#" class="number" title="4">4</a> <a href="#" title="Next Page">Next > </a><a href="#" title="Last Page">Last >> </a> </div> <!-- End .pagination --> <div class="clear"></div> </td> </tr> </tfoot> <tbody> <tr class="alt-row"> <td><input type="checkbox"></td> <td>Lorem ipsum dolor</td> <td><a href="#" title="title">Sit amet</a></td> <td>Consectetur adipiscing</td> <td>Donec tortor diam</td> <td> <!-- Icons --> <a href="#" title="Edit"><img src="<?php echo Yii::app()->request->baseUrl; ?>/css/admin/images/icons/pencil.png" alt="Edit"></a> <a href="#" title="Delete"><img src="<?php echo Yii::app()->request->baseUrl; ?>/css/admin/images/icons/cross.png" alt="Delete"></a> <a href="#" title="Edit Meta"><img src="<?php echo Yii::app()->request->baseUrl; ?>/css/admin/images/icons/hammer_screwdriver.png" alt="Edit Meta"></a> </td> </tr> <tr> <td><input type="checkbox"></td> <td>Lorem ipsum dolor</td> <td><a href="#" title="title">Sit amet</a></td> <td>Consectetur adipiscing</td> <td>Donec tortor diam</td> <td> <!-- Icons --> <a href="#" title="Edit"><img src="<?php echo Yii::app()->request->baseUrl; ?>/css/admin/images/icons/pencil.png" alt="Edit"></a> <a href="#" title="Delete"><img src="<?php echo Yii::app()->request->baseUrl; ?>/css/admin/images/icons/cross.png" alt="Delete"></a> <a href="#" title="Edit Meta"><img src="<?php echo Yii::app()->request->baseUrl; ?>/css/admin/images/icons/hammer_screwdriver.png" alt="Edit Meta"></a> </td> </tr> </tbody> </table> </div> <!-- End #tab1 --> <div class="tab-content" id="tab2" style="display: none;"> <form action="" method="post"> <fieldset> <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns --> <p> <label>Title</label> <input class="text-input medium-input" type="text" id="medium-input" name="medium-input"> <span class="input-notification error png_bg">Error message</span> </p> <p> <label>Checkboxes</label> <label for="checkbox1"> <input type="checkbox" id="checkbox1" name="checkbox1"> Hot</label> <label for="checkbox2"> <input type="checkbox" id="checkbox2" name="checkbox2"> New</label> </p> <p> <label>Category</label> <select name="dropdown" class="small-input"> <option value="option1">Option 1</option> <option value="option2">Option 2</option> <option value="option3">Option 3</option> <option value="option4">Option 4</option> </select> </p> <p> <label>Textarea with WYSIWYG</label> <textarea class="text-input textarea wysiwyg" id="textarea" name="textfield" cols="79" rows="15"></textarea> </p> <p> <input class="button" type="submit" value="Submit"> </p> </fieldset> <div class="clear"></div><!-- End .clear --> </form> </div> <!-- End #tab2 --> </div> </div>
bsd-3-clause
ncollins/ocr_training_data
README.md
108
ocr_training_data ================= Generate training data for Optical Character Recognition with Python.
bsd-3-clause
skeeks-cms/cms-backend
src/assets/BackendAsset.php
679
<?php /** * @author Semenov Alexander <[email protected]> * @link http://skeeks.com/ * @copyright 2010 SkeekS (СкикС) * @date 27.04.2016 */ namespace skeeks\cms\backend\assets; use skeeks\cms\base\AssetBundle; use yii\bootstrap\BootstrapAsset; /** * Class SelectLanguage * @package common\widgets\selectLanguage */ class BackendAsset extends AssetBundle { public $sourcePath = '@skeeks/cms/backend/assets/src'; public $css = [ 'backend.css', ]; public $js = [ 'backend.js', ]; public $depends = [ 'yii\web\YiiAsset', 'skeeks\sx\assets\Custom', 'skeeks\sx\assets\ComponentAjaxLoader', ]; }
bsd-3-clause
kkaempf/openwbem
src/requesthandlers/binary/OW_BinaryRequestHandler.cpp
35938
/******************************************************************************* * Copyright (C) 2001-2004 Vintela, Inc. All rights reserved. * * 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 Vintela, 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 Vintela, Inc. OR THE 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. *******************************************************************************/ /** * @author Jon Carey * @author Dan Nuffer */ #include "OW_config.h" #include "OW_ConfigOpts.hpp" #include "OW_FileSystem.hpp" #include "OW_BinaryRequestHandler.hpp" #include "OW_BinarySerialization.hpp" #include "OW_Format.hpp" #include "OW_CIMOMHandleIFC.hpp" #include "OW_CIMFeatures.hpp" #include "OW_CIMParamValue.hpp" #include "OW_SocketUtils.hpp" #include "OW_CIMException.hpp" #include "OW_CIMProperty.hpp" #include "OW_CIMQualifier.hpp" #include "OW_Mutex.hpp" #include "OW_MutexLock.hpp" #include "OW_SocketException.hpp" #include "OW_ThreadCancelledException.hpp" #include "OW_Logger.hpp" #include "OW_OperationContext.hpp" #include "OW_UserUtils.hpp" #include "OW_ServiceIFCNames.hpp" #include "OW_ResultHandlerIFC.hpp" #include <exception> namespace OW_NAMESPACE { namespace { const String COMPONENT_NAME("ow.requesthandler.owbinary"); } using namespace WBEMFlags; ////////////////////////////////////////////////////////////////////////////// BinaryRequestHandler::BinaryRequestHandler() : RequestHandlerIFC() , m_userId(UserId(-1)) { } ////////////////////////////////////////////////////////////////////////////// RequestHandlerIFC* BinaryRequestHandler::clone() const { return new BinaryRequestHandler(*this); } ////////////////////////////////////////////////////////////////////////////// String BinaryRequestHandler::getName() const { return ServiceIFCNames::BinaryRequestHandler; } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::setEnvironment(const ServiceEnvironmentIFCRef& env) { RequestHandlerIFC::setEnvironment(env); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::doOptions(CIMFeatures& cf, OperationContext&) { cf.cimom = "openwbem"; cf.cimProduct = CIMFeatures::SERVER; cf.extURL = "local_binary"; cf.protocolVersion = OW_VERSION; cf.supportedGroups.clear(); cf.supportedQueryLanguages.clear(); cf.supportedQueryLanguages.append("WQL"); cf.supportsBatch = false; cf.validation.erase(); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::doProcess(std::istream* istrm, std::ostream *ostrm, std::ostream* ostrError, OperationContext& context) { clearError(); String userName = context.getStringDataWithDefault(OperationContext::USER_NAME); if (!userName.empty()) { bool validUserName = false; m_userId = UserUtils::getUserId(userName, validUserName); if (!validUserName) { m_userId = UserId(-1); } } UInt8 funcNo = 0; LoggerRef lgr = getEnvironment()->getLogger(COMPONENT_NAME); try { CIMOMHandleIFCRef chdl = getEnvironment()->getCIMOMHandle(context); UInt32 version = 0; BinarySerialization::read(*istrm, version); if (version < MinBinaryProtocolVersion || version > BinaryProtocolVersion) { OW_THROWCIMMSG(CIMException::FAILED, "Incompatible version"); } BinarySerialization::read(*istrm, funcNo); try { switch (funcNo) { case BIN_GETQUAL: OW_LOG_DEBUG(lgr, "BinaryRequestHandler get qualifier" " request"); getQual(chdl, *ostrm, *istrm); break; #ifndef OW_DISABLE_QUALIFIER_DECLARATION case BIN_SETQUAL: OW_LOG_DEBUG(lgr, "BinaryRequestHandler set qualifier" " request"); setQual(chdl, *ostrm, *istrm); break; case BIN_DELETEQUAL: OW_LOG_DEBUG(lgr, "BinaryRequestHandler delete qualifier" " request"); deleteQual(chdl, *ostrm, *istrm); break; case BIN_ENUMQUALS: OW_LOG_DEBUG(lgr, "BinaryRequestHandler enum qualifiers" " request"); enumQualifiers(chdl, *ostrm, *istrm); break; #endif // #ifndef OW_DISABLE_QUALIFIER_DECLARATION case BIN_GETCLS: OW_LOG_DEBUG(lgr, "BinaryRequestHandler get class" " request"); getClass(chdl, *ostrm, *istrm); break; #ifndef OW_DISABLE_SCHEMA_MANIPULATION case BIN_CREATECLS: OW_LOG_DEBUG(lgr, "BinaryRequestHandler create class" " request"); createClass(chdl, *ostrm, *istrm); break; case BIN_MODIFYCLS: OW_LOG_DEBUG(lgr, "BinaryRequestHandler modify class" " request"); modifyClass(chdl, *ostrm, *istrm); break; case BIN_DELETECLS: OW_LOG_DEBUG(lgr, "BinaryRequestHandler delete class" " request"); deleteClass(chdl, *ostrm, *istrm); break; #endif // #ifndef OW_DISABLE_SCHEMA_MANIPULATION case BIN_ENUMCLSS: OW_LOG_DEBUG(lgr, "BinaryRequestHandler enum classes" " request"); enumClasses(chdl, *ostrm, *istrm); break; case BIN_GETINST: OW_LOG_DEBUG(lgr, "BinaryRequestHandler get instance" " request"); getInstance(chdl, *ostrm, *istrm); break; #ifndef OW_DISABLE_INSTANCE_MANIPULATION case BIN_CREATEINST: OW_LOG_DEBUG(lgr, "BinaryRequestHandler create instance" " request"); createInstance(chdl, *ostrm, *istrm); break; case BIN_MODIFYINST: OW_LOG_DEBUG(lgr, "BinaryRequestHandler get instance" " request"); modifyInstance(chdl, *ostrm, *istrm); break; case BIN_DELETEINST: OW_LOG_DEBUG(lgr, "BinaryRequestHandler delete instance" " request"); deleteInstance(chdl, *ostrm, *istrm); break; #if !defined(OW_DISABLE_PROPERTY_OPERATIONS) case BIN_SETPROP: OW_LOG_DEBUG(lgr, "BinaryRequestHandler set property" " request"); setProperty(chdl, *ostrm, *istrm); break; #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS) #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION #if !defined(OW_DISABLE_PROPERTY_OPERATIONS) case BIN_GETPROP: OW_LOG_DEBUG(lgr, "BinaryRequestHandler get property" " request"); getProperty(chdl, *ostrm, *istrm); break; #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS) case BIN_ENUMCLSNAMES: OW_LOG_DEBUG(lgr, "BinaryRequestHandler enum class names" " request"); enumClassNames(chdl, *ostrm, *istrm); break; case BIN_ENUMINSTS: OW_LOG_DEBUG(lgr, "BinaryRequestHandler enum instances" " request"); enumInstances(chdl, *ostrm, *istrm); break; case BIN_ENUMINSTNAMES: OW_LOG_DEBUG(lgr, "BinaryRequestHandler enum instance" " names request"); enumInstanceNames(chdl, *ostrm, *istrm); break; case BIN_INVMETH: OW_LOG_DEBUG(lgr, "BinaryRequestHandler invoke method" " request"); invokeMethod(chdl, *ostrm, *istrm); break; case BIN_EXECQUERY: OW_LOG_DEBUG(lgr, "BinaryRequestHandler exec query" " request"); execQuery(chdl, *ostrm, *istrm); break; #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL case BIN_ASSOCIATORS: OW_LOG_DEBUG(lgr, "BinaryRequestHandler associators" " request"); associators(chdl, *ostrm, *istrm); break; case BIN_ASSOCNAMES: OW_LOG_DEBUG(lgr, "BinaryRequestHandler associator names" " request"); associatorNames(chdl, *ostrm, *istrm); break; case BIN_REFERENCES: OW_LOG_DEBUG(lgr, "BinaryRequestHandler references" " request"); references(chdl, *ostrm, *istrm); break; case BIN_REFNAMES: OW_LOG_DEBUG(lgr, "BinaryRequestHandler reference names" " request"); referenceNames(chdl, *ostrm, *istrm); break; #endif case BIN_GETSVRFEATURES: OW_LOG_DEBUG(lgr, "BinaryRequestHandler get server" " features request"); getServerFeatures(chdl, *ostrm, *istrm); break; default: OW_LOG_DEBUG(lgr, Format("BinaryRequestHandler: Received" " invalid function number: %1", funcNo)); writeError(*ostrError, "Invalid function number"); break; } } catch(CIMException& e) { OW_LOG_INFO(lgr, Format("CIM Exception caught in" " BinaryRequestHandler: %1", e)); BinarySerialization::write(*ostrError, BIN_EXCEPTION); BinarySerialization::write(*ostrError, UInt16(e.getErrNo())); BinarySerialization::write(*ostrError, e.getMessage()); setError(e.getErrNo(), e.getDescription()); } } catch(Exception& e) { OW_LOG_ERROR(lgr, "Exception caught in BinaryRequestHandler"); OW_LOG_ERROR(lgr, Format("Type: %1", e.type())); OW_LOG_ERROR(lgr, Format("File: %1", e.getFile())); OW_LOG_ERROR(lgr, Format("Line: %1", e.getLine())); OW_LOG_ERROR(lgr, Format("Msg: %1", e.getMessage())); writeError(*ostrError, Format("BinaryRequestHandler caught exception: %1", e).c_str()); setError(CIMException::FAILED, e.getMessage()); } catch(std::exception& e) { OW_LOG_ERROR(lgr, Format("Caught %1 exception in BinaryRequestHandler", e.what())); writeError(*ostrError, Format("BinaryRequestHandler caught exception: %1", e.what()).c_str()); setError(CIMException::FAILED, e.what()); } catch (ThreadCancelledException&) { OW_LOG_ERROR(lgr, "Thread cancelled in BinaryRequestHandler"); writeError(*ostrError, "Thread cancelled"); setError(CIMException::FAILED, "Thread cancelled"); throw; } catch(...) { OW_LOG_ERROR(lgr, "Unknown exception caught in BinaryRequestHandler"); writeError(*ostrError, "BinaryRequestHandler caught unknown exception"); setError(CIMException::FAILED, "Caught unknown exception"); } } #ifndef OW_DISABLE_SCHEMA_MANIPULATION ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::createClass(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMClass cc(BinarySerialization::readClass(istrm)); chdl->createClass(ns, cc); BinarySerialization::write(ostrm, BIN_OK); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::modifyClass(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMClass cc(BinarySerialization::readClass(istrm)); chdl->modifyClass(ns, cc); BinarySerialization::write(ostrm, BIN_OK); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::deleteClass(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); String className(BinarySerialization::readString(istrm)); chdl->deleteClass(ns, className); BinarySerialization::write(ostrm, BIN_OK); } #endif // #ifndef OW_DISABLE_SCHEMA_MANIPULATION ////////////////////////////////////////////////////////////////////////////// namespace { class BinaryCIMClassWriter : public CIMClassResultHandlerIFC { public: BinaryCIMClassWriter(std::ostream& ostrm_) : ostrm(ostrm_) {} protected: virtual void doHandle(const CIMClass &c) { BinarySerialization::writeClass(ostrm, c); } private: std::ostream& ostrm; }; class BinaryCIMObjectPathWriter : public CIMObjectPathResultHandlerIFC { public: BinaryCIMObjectPathWriter(std::ostream& ostrm_, const String& host_) : ostrm(ostrm_) , m_host(host_) {} protected: virtual void doHandle(const CIMObjectPath &cop_) { // Make sure all outgoing object paths have our host name, instead of 127.0.0.1 CIMObjectPath cop(cop_); if (cop.getFullNameSpace().isLocal()) { try { cop.setHost(m_host); } catch (const SocketException& e) { } } BinarySerialization::writeObjectPath(ostrm, cop); } private: std::ostream& ostrm; String m_host; }; class BinaryCIMInstanceWriter : public CIMInstanceResultHandlerIFC { public: BinaryCIMInstanceWriter(std::ostream& ostrm_, const String& ns_) : ostrm(ostrm_) , ns(ns_) {} protected: virtual void doHandle(const CIMInstance &cop) { if (cop.getNameSpace().empty()) { CIMInstance ci(cop); ci.setNameSpace(ns); BinarySerialization::writeInstance(ostrm, ci); } else { BinarySerialization::writeInstance(ostrm, cop); } } private: std::ostream& ostrm; String ns; }; class BinaryCIMQualifierTypeWriter : public CIMQualifierTypeResultHandlerIFC { public: BinaryCIMQualifierTypeWriter(std::ostream& ostrm_) : ostrm(ostrm_) {} protected: virtual void doHandle(const CIMQualifierType &cqt) { BinarySerialization::writeQualType(ostrm, cqt); } private: std::ostream& ostrm; }; class BinaryStringWriter : public StringResultHandlerIFC { public: BinaryStringWriter(std::ostream& ostrm_) : ostrm(ostrm_) {} protected: virtual void doHandle(const String &name) { BinarySerialization::writeString(ostrm, name); } private: std::ostream& ostrm; String ns; }; } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::enumClasses(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); String className(BinarySerialization::readString(istrm)); EDeepFlag deep(BinarySerialization::readBool(istrm) ? E_DEEP : E_SHALLOW); ELocalOnlyFlag localOnly(BinarySerialization::readBool(istrm) ? E_LOCAL_ONLY : E_NOT_LOCAL_ONLY); EIncludeQualifiersFlag includeQualifiers(BinarySerialization::readBool(istrm) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS); EIncludeClassOriginFlag includeClassOrigin(BinarySerialization::readBool(istrm) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, BINSIG_CLSENUM); BinaryCIMClassWriter handler(ostrm); chdl->enumClass(ns, className, handler, deep, localOnly, includeQualifiers, includeClassOrigin); BinarySerialization::write(ostrm, END_CLSENUM); BinarySerialization::write(ostrm, END_CLSENUM); } #ifndef OW_DISABLE_QUALIFIER_DECLARATION ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::deleteQual(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); String qualName(BinarySerialization::readString(istrm)); chdl->deleteQualifierType(ns, qualName); BinarySerialization::write(ostrm, BIN_OK); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::setQual(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMQualifierType qt(BinarySerialization::readQualType(istrm)); chdl->setQualifierType(ns, qt); BinarySerialization::write(ostrm, BIN_OK); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::enumQualifiers(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, BINSIG_QUAL_TYPEENUM); BinaryCIMQualifierTypeWriter handler(ostrm); chdl->enumQualifierTypes(ns, handler); BinarySerialization::write(ostrm, END_QUALENUM); BinarySerialization::write(ostrm, END_QUALENUM); } #endif // #ifndef OW_DISABLE_QUALIFIER_DECLARATION ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::getClass(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { StringArray propList; StringArray* propListPtr = 0; String ns(BinarySerialization::readString(istrm)); String className(BinarySerialization::readString(istrm)); ELocalOnlyFlag localOnly(BinarySerialization::readBool(istrm) ? E_LOCAL_ONLY : E_NOT_LOCAL_ONLY); EIncludeQualifiersFlag includeQualifiers(BinarySerialization::readBool(istrm) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS); EIncludeClassOriginFlag includeClassOrigin(BinarySerialization::readBool(istrm) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN); Bool nullPropertyList(BinarySerialization::readBool(istrm)); if (!nullPropertyList) { propList = BinarySerialization::readStringArray(istrm); propListPtr = &propList; } CIMClass cc = chdl->getClass(ns, className, localOnly, includeQualifiers, includeClassOrigin, propListPtr); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::writeClass(ostrm, cc); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::getInstance(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMObjectPath op(BinarySerialization::readObjectPath(istrm)); ELocalOnlyFlag localOnly(BinarySerialization::readBool(istrm) ? E_LOCAL_ONLY : E_NOT_LOCAL_ONLY); EIncludeQualifiersFlag includeQualifiers(BinarySerialization::readBool(istrm) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS); EIncludeClassOriginFlag includeClassOrigin(BinarySerialization::readBool(istrm) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN); StringArray propList; StringArray* propListPtr = 0; Bool nullPropertyList(BinarySerialization::readBool(istrm)); if (!nullPropertyList) { propList = BinarySerialization::readStringArray(istrm); propListPtr = &propList; } CIMInstance cimInstance = chdl->getInstance(ns, op, localOnly, includeQualifiers, includeClassOrigin, propListPtr); if (cimInstance.getNameSpace().empty()) cimInstance.setNameSpace(ns); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::writeInstance(ostrm, cimInstance); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::getQual(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); String qualifierName(BinarySerialization::readString(istrm)); CIMQualifierType qt = chdl->getQualifierType(ns, qualifierName); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::writeQualType(ostrm, qt); } #ifndef OW_DISABLE_INSTANCE_MANIPULATION ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::createInstance(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMInstance cimInstance(BinarySerialization::readInstance(istrm)); CIMName className = cimInstance.getClassName(); //CIMObjectPath realPath(className, path.getNameSpace()); // Special treatment for __Namespace class if (className == "__Namespace") { CIMProperty prop = cimInstance.getProperty( CIMProperty::NAME_PROPERTY); // Need the name property since it contains the name of the new // name space if (!prop) { OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, "Name property not specified for new namespace"); } // If the name property didn't come acrossed as a key, then // set the name property as the key if (!prop.isKey()) { prop.addQualifier(CIMQualifier::createKeyQualifier()); } cimInstance.setProperty(prop); } /* This should be done in the CIM Server CIMPropertyArray keys = cimInstance.getKeyValuePairs(); if (keys.size() == 0) { OW_THROWCIMMSG(CIMException::FAILED,"Instance doesn't have keys"); } for (size_t i = 0; i < keys.size(); ++i) { CIMProperty key = keys[i]; if (!key.getValue()) { OW_THROWCIMMSG(CIMException::FAILED, Format("Key must be provided! Property \"%1\" does not have a " "valid value.", key.getName()).c_str()); } } realPath.setKeys(keys); */ CIMObjectPath newPath = chdl->createInstance(ns, cimInstance); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::writeObjectPath(ostrm, newPath); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::deleteInstance(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMObjectPath op(BinarySerialization::readObjectPath(istrm)); chdl->deleteInstance(ns, op); BinarySerialization::write(ostrm, BIN_OK); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::modifyInstance(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMInstance ci(BinarySerialization::readInstance(istrm)); EIncludeQualifiersFlag includeQualifiers(BinarySerialization::readBool(istrm) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS); StringArray propList; StringArray* propListPtr = 0; Bool nullPropertyList(BinarySerialization::readBool(istrm)); if (!nullPropertyList) { propList = BinarySerialization::readStringArray(istrm); propListPtr = &propList; } chdl->modifyInstance(ns, ci, includeQualifiers, propListPtr); BinarySerialization::write(ostrm, BIN_OK); } #if !defined(OW_DISABLE_PROPERTY_OPERATIONS) ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::setProperty(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMObjectPath op(BinarySerialization::readObjectPath(istrm)); String propName(BinarySerialization::readString(istrm)); Bool isValue(BinarySerialization::readBool(istrm)); CIMValue cv(CIMNULL); if (isValue) { cv = BinarySerialization::readValue(istrm); } chdl->setProperty(ns, op, propName, cv); BinarySerialization::write(ostrm, BIN_OK); } #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS) #endif // #ifndef OW_DISABLE_INSTANCE_MANIPULATION #if !defined(OW_DISABLE_PROPERTY_OPERATIONS) ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::getProperty(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns (BinarySerialization::readString(istrm)); CIMObjectPath op(BinarySerialization::readObjectPath(istrm)); String propName(BinarySerialization::readString(istrm)); CIMValue cv = chdl->getProperty(ns, op, propName); BinarySerialization::write(ostrm, BIN_OK); Bool isValue = (cv) ? true : false; BinarySerialization::writeBool(ostrm, isValue); if (isValue) { BinarySerialization::writeValue(ostrm, cv); } } #endif // #if !defined(OW_DISABLE_PROPERTY_OPERATIONS) ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::enumClassNames(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); String className(BinarySerialization::readString(istrm)); EDeepFlag deep(BinarySerialization::readBool(istrm) ? E_DEEP : E_SHALLOW); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, BINSIG_STRINGENUM); BinaryStringWriter handler(ostrm); chdl->enumClassNames(ns, className, handler, deep); BinarySerialization::write(ostrm, END_STRINGENUM); BinarySerialization::write(ostrm, END_STRINGENUM); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::enumInstances(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { StringArray propList; StringArray* propListPtr = 0; String ns(BinarySerialization::readString(istrm)); String className(BinarySerialization::readString(istrm)); EDeepFlag deep(BinarySerialization::readBool(istrm) ? E_DEEP : E_SHALLOW); ELocalOnlyFlag localOnly(BinarySerialization::readBool(istrm) ? E_LOCAL_ONLY : E_NOT_LOCAL_ONLY); EIncludeQualifiersFlag includeQualifiers(BinarySerialization::readBool(istrm) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS); EIncludeClassOriginFlag includeClassOrigin(BinarySerialization::readBool(istrm) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN); Bool nullPropertyList(BinarySerialization::readBool(istrm)); if (!nullPropertyList) { propList = BinarySerialization::readStringArray(istrm); propListPtr = &propList; } BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, BINSIG_INSTENUM); BinaryCIMInstanceWriter handler(ostrm, ns); chdl->enumInstances(ns, className, handler, deep, localOnly, includeQualifiers, includeClassOrigin, propListPtr); BinarySerialization::write(ostrm, END_INSTENUM); BinarySerialization::write(ostrm, END_INSTENUM); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::enumInstanceNames(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); String className(BinarySerialization::readString(istrm)); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, BINSIG_OPENUM); BinaryCIMObjectPathWriter handler(ostrm, getHost()); chdl->enumInstanceNames(ns, className, handler); BinarySerialization::write(ostrm, END_OPENUM); BinarySerialization::write(ostrm, END_OPENUM); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::invokeMethod(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns (BinarySerialization::readString(istrm)); CIMObjectPath path(BinarySerialization::readObjectPath(istrm)); String methodName(BinarySerialization::readString(istrm)); CIMParamValueArray inparms; CIMParamValueArray outparms; // Get input params BinarySerialization::verifySignature(istrm, BINSIG_PARAMVALUEARRAY); BinarySerialization::readArray(istrm, inparms); CIMValue cv = chdl->invokeMethod(ns, path, methodName, inparms, outparms); BinarySerialization::write(ostrm, BIN_OK); if (cv) { BinarySerialization::writeBool(ostrm, Bool(true)); BinarySerialization::writeValue(ostrm, cv); } else { BinarySerialization::writeBool(ostrm, Bool(false)); } BinarySerialization::write(ostrm, BINSIG_PARAMVALUEARRAY); BinarySerialization::writeArray(ostrm, outparms); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::execQuery(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); String query(BinarySerialization::readString(istrm)); String queryLang(BinarySerialization::readString(istrm)); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, BINSIG_INSTENUM); BinaryCIMInstanceWriter handler(ostrm, ns); chdl->execQuery(ns, handler, query, queryLang); BinarySerialization::write(ostrm, END_INSTENUM); BinarySerialization::write(ostrm, END_INSTENUM); } #ifndef OW_DISABLE_ASSOCIATION_TRAVERSAL ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::associators(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { StringArray propList; StringArray* propListPtr = 0; String ns(BinarySerialization::readString(istrm)); CIMObjectPath op(BinarySerialization::readObjectPath(istrm)); String assocClass(BinarySerialization::readString(istrm)); String resultClass(BinarySerialization::readString(istrm)); String role(BinarySerialization::readString(istrm)); String resultRole(BinarySerialization::readString(istrm)); EIncludeQualifiersFlag includeQualifiers(BinarySerialization::readBool(istrm) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS); EIncludeClassOriginFlag includeClassOrigin(BinarySerialization::readBool(istrm) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN); Bool nullPropertyList(BinarySerialization::readBool(istrm)); if (!nullPropertyList) { propList = BinarySerialization::readStringArray(istrm); propListPtr = &propList; } BinarySerialization::write(ostrm, BIN_OK); if (op.isClassPath()) { // class path BinarySerialization::write(ostrm, BINSIG_CLSENUM); BinaryCIMClassWriter handler(ostrm); op.setNameSpace(ns); chdl->associatorsClasses(ns, op, handler, assocClass, resultClass, role, resultRole, includeQualifiers, includeClassOrigin, propListPtr); BinarySerialization::write(ostrm, END_CLSENUM); BinarySerialization::write(ostrm, END_CLSENUM); } else { // instance path BinarySerialization::write(ostrm, BINSIG_INSTENUM); BinaryCIMInstanceWriter handler(ostrm, ns); chdl->associators(ns, op, handler, assocClass, resultClass, role, resultRole, includeQualifiers, includeClassOrigin, propListPtr); BinarySerialization::write(ostrm, END_INSTENUM); BinarySerialization::write(ostrm, END_INSTENUM); } } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::associatorNames(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMObjectPath op(BinarySerialization::readObjectPath(istrm)); String assocClass(BinarySerialization::readString(istrm)); String resultClass(BinarySerialization::readString(istrm)); String role(BinarySerialization::readString(istrm)); String resultRole(BinarySerialization::readString(istrm)); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, BINSIG_OPENUM); BinaryCIMObjectPathWriter handler(ostrm, getHost()); chdl->associatorNames(ns, op, handler, assocClass, resultClass, role, resultRole); BinarySerialization::write(ostrm, END_OPENUM); BinarySerialization::write(ostrm, END_OPENUM); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::references(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { StringArray propList; StringArray* propListPtr = 0; String ns(BinarySerialization::readString(istrm)); CIMObjectPath op(BinarySerialization::readObjectPath(istrm)); String resultClass(BinarySerialization::readString(istrm)); String role(BinarySerialization::readString(istrm)); EIncludeQualifiersFlag includeQualifiers(BinarySerialization::readBool(istrm) ? E_INCLUDE_QUALIFIERS : E_EXCLUDE_QUALIFIERS); EIncludeClassOriginFlag includeClassOrigin(BinarySerialization::readBool(istrm) ? E_INCLUDE_CLASS_ORIGIN : E_EXCLUDE_CLASS_ORIGIN); Bool nullPropertyList(BinarySerialization::readBool(istrm)); if (!nullPropertyList) { propList = BinarySerialization::readStringArray(istrm); propListPtr = &propList; } BinarySerialization::write(ostrm, BIN_OK); if (op.isClassPath()) { // class path BinarySerialization::write(ostrm, BINSIG_CLSENUM); BinaryCIMClassWriter handler(ostrm); chdl->referencesClasses(ns, op, handler, resultClass, role, includeQualifiers, includeClassOrigin, propListPtr); BinarySerialization::write(ostrm, END_CLSENUM); BinarySerialization::write(ostrm, END_CLSENUM); } else { // instance path BinarySerialization::write(ostrm, BINSIG_INSTENUM); BinaryCIMInstanceWriter handler(ostrm, ns); chdl->references(ns, op, handler, resultClass, role, includeQualifiers, includeClassOrigin, propListPtr); BinarySerialization::write(ostrm, END_INSTENUM); BinarySerialization::write(ostrm, END_INSTENUM); } } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::referenceNames(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& istrm) { String ns(BinarySerialization::readString(istrm)); CIMObjectPath op(BinarySerialization::readObjectPath(istrm)); String resultClass(BinarySerialization::readString(istrm)); String role(BinarySerialization::readString(istrm)); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, BINSIG_OPENUM); BinaryCIMObjectPathWriter handler(ostrm, getHost()); chdl->referenceNames(ns, op, handler, resultClass, role); BinarySerialization::write(ostrm, END_OPENUM); BinarySerialization::write(ostrm, END_OPENUM); } #endif ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::getServerFeatures(const CIMOMHandleIFCRef& chdl, std::ostream& ostrm, std::istream& /*istrm*/) { CIMFeatures f = chdl->getServerFeatures(); BinarySerialization::write(ostrm, BIN_OK); BinarySerialization::write(ostrm, Int32(f.cimProduct)); BinarySerialization::writeString(ostrm, f.extURL); BinarySerialization::writeStringArray(ostrm, f.supportedGroups); BinarySerialization::writeBool(ostrm, f.supportsBatch); BinarySerialization::writeStringArray(ostrm, f.supportedQueryLanguages); BinarySerialization::writeString(ostrm, f.validation); BinarySerialization::writeString(ostrm, f.cimom); BinarySerialization::writeString(ostrm, f.protocolVersion); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::writeError(std::ostream& ostrm, const char* msg) { BinarySerialization::write(ostrm, BIN_ERROR); BinarySerialization::write(ostrm, msg); } ////////////////////////////////////////////////////////////////////////////// bool BinaryRequestHandler::writeFileName(std::ostream& ostrm, const String& fname) { LoggerRef lgr = getEnvironment()->getLogger(COMPONENT_NAME); if (m_userId == UserId(-1)) { OW_LOG_ERROR(lgr, "Binary request handler cannot change file ownership:" " Owner unknown"); return false; } try { if (FileSystem::changeFileOwner(fname, m_userId) != 0) { OW_LOG_ERROR(lgr, Format("Binary request handler failed changing" " ownership on file %1", fname)); return false; } // Write -1 to indicate file name follows BinarySerialization::write(ostrm, Int32(-1)); // Write file name BinarySerialization::writeString(ostrm, fname); } catch(...) { FileSystem::removeFile(fname); throw; } return true; } ////////////////////////////////////////////////////////////////////////////// StringArray BinaryRequestHandler::getSupportedContentTypes() const { StringArray rval; rval.push_back("application/x-owbinary"); return rval; } ////////////////////////////////////////////////////////////////////////////// String BinaryRequestHandler::getContentType() const { return String("application/x-owbinary"); } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::init(const ServiceEnvironmentIFCRef& env) { } ////////////////////////////////////////////////////////////////////////////// void BinaryRequestHandler::shutdown() { } } // end namespace OW_NAMESPACE ////////////////////////////////////////////////////////////////////////////// OW_REQUEST_HANDLER_FACTORY(OW_NAMESPACE::BinaryRequestHandler,BinaryRequest);
bsd-3-clause
hjwylde/scotland-yard
app/controllers/nodes_controller.rb
500
require_relative '../concepts/board' class NodesController < ApplicationController before_action :load_nodes, only: :index before_action :load_routes, only: :index before_action :load_board, only: :index respond_to :json caches_page :index def index render json: @nodes, board: @board end private def load_nodes @nodes = Node.all end def load_routes @routes = Route.all end def load_board @board = Board.new(nodes: @nodes, routes: @routes) end end
bsd-3-clause
Amaceika/TowerWall
twitter-oauth/jquery.jstwitter.js
6798
$(function() { JQTWEET = { // Set twitter hash/user, number of tweets & id/class to append tweets // You need to clear tweet-date.txt before toggle between hash and user // for multiple hashtags, you can separate the hashtag with OR, eg: search: '', //leave this blank if you want to show user's tweet hash: '', user: '', //username numTweets:500, //number of tweets appendTo: '', useGridalicious: false, template: '<div class="item"> <div class="time"><p>{AGO}</p></div>\ <div class="tweet-wrapper">\ <div class="profile"><img href="{PHO}" src="{PHOP}"/></div>\ <div class="user">{USER}</div>\ <div class="text">{TEXT}</div><div class="img">{IMG}</div></div></div>', // core function of jqtweet // https://dev.twitter.com/docs/using-search loadTweets: function() { //console.log("We Made it here"); var request; // different JSON request {hash|user} if (JQTWEET.search) { request = { q: JQTWEET.search, count: JQTWEET.numTweets, api: 'search_tweets' } } else { request = { q: JQTWEET.user, count: JQTWEET.numTweets, api: 'statuses_userTimeline' } } $.ajax({ url: 'grabtweets.php', type: 'POST', dataType: 'json', data: request, success: function(data, textStatus, xhr) { if (data.httpstatus == 200) { if (JQTWEET.search) data = data.statuses; var text, name, img; try { // append tweets into page for (var i = 0; i < JQTWEET.numTweets; i++) { img = ''; url = 'http://twitter.com/' + data[i].user.screen_name + '/status/' + data[i].id_str; try { if (data[i].entities['media']) { img = '<img src="' + data[i].entities['media'][0].media_url + '" />'; } } catch (e) { //no media } $(JQTWEET.appendTo).append( JQTWEET.template.replace('{TEXT}', JQTWEET.ify.clean(data[i].text) ) .replace('{USER}', data[i].user.screen_name) .replace('{PHO}', data[i].user.profile_image_url) .replace('{PHOP}', data[i].user.profile_image_url) .replace('{IMG}', img) .replace('{AGO}', JQTWEET.timeAgo(data[i].created_at) ) .replace('{URL}', url ) ); } } catch (e) { //item is less than item count } if (JQTWEET.useGridalicious) { //run grid-a-licious $(JQTWEET.appendTo).gridalicious({ gutter: 13, width: 1080, animate: true }); } } else alert('no data returned'); } }); }, /** * relative time calculator FROM TWITTER * @param {string} twitter date string returned from Twitter API * @return {string} relative time like "2 minutes ago" */ timeAgo: function(dateString) { var rightNow = new Date(); var then = new Date(dateString); if ($.browser.msie) { // IE can't parse these crazy Ruby dates then = Date.parse(dateString.replace(/( \+)/, ' UTC$1')); } var diff = rightNow - then; var second = 1000, minute = second * 60, hour = minute * 60, day = hour * 24, week = day * 7; if (isNaN(diff) || diff < 0) { return ""; // return blank string if unknown } if (diff < second * 2) { // within 2 seconds return "right now"; } if (diff < minute) { return Math.floor(diff / second) + " seconds ago"; } if (diff < minute * 2) { return "about 1 minute ago"; } if (diff < hour) { return Math.floor(diff / minute) + " minutes ago"; } if (diff < hour * 2) { return "about 1 hour ago"; } if (diff < day) { return Math.floor(diff / hour) + " hours ago"; } if (diff > day && diff < day * 2) { return "yesterday"; } if (diff < day * 365) { return Math.floor(diff / day) + " days ago"; } else { return "over a year ago"; } }, // timeAgo() /** * The Twitalinkahashifyer! * http://www.dustindiaz.com/basement/ify.html * Eg: * ify.clean('your tweet text'); */ ify: { link: function(tweet) { return tweet.replace(/\b(((https*\:\/\/)|www\.)[^\"\']+?)(([!?,.\)]+)?(\s|$))/g, function(link, m1, m2, m3, m4) { var http = m2.match(/w/) ? 'http://' : ''; return '<a class="twtr-hyperlink" target="_blank" href="' + http + m1 + '">' + ((m1.length > 25) ? m1.substr(0, 24) + '...' : m1) + '</a>' + m4; }); }, at: function(tweet) { return tweet.replace(/\B[@@]([a-zA-Z0-9_]{1,20})/g, function(m, username) { return '<a target="_blank" class="twtr-atreply" href="http://twitter.com/intent/user?screen_name=' + username + '">@' + username + '</a>'; }); }, list: function(tweet) { return tweet.replace(/\B[@@]([a-zA-Z0-9_]{1,20}\/\w+)/g, function(m, userlist) { return '<a target="_blank" class="twtr-atreply" href="http://twitter.com/' + userlist + '">@' + userlist + '</a>'; }); }, hash: function(tweet) { return tweet.replace(/(^|\s+)#(\w+)/gi, function(m, before, hash) { return before + '<a target="_blank" class="twtr-hashtag" href="http://twitter.com/search?q=%23' + hash + '">#' + hash + '</a>'; }); }, clean: function(tweet) { return this.hash(this.at(this.list(this.link(tweet)))); } } // ify }; });
bsd-3-clause
fujunwei/chromium-crosswalk
content/renderer/input/input_handler_proxy.cc
35811
// Copyright 2013 The Chromium 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 "content/renderer/input/input_handler_proxy.h" #include "base/auto_reset.h" #include "base/command_line.h" #include "base/logging.h" #include "base/metrics/histogram.h" #include "base/trace_event/trace_event.h" #include "content/common/input/did_overscroll_params.h" #include "content/common/input/web_input_event_traits.h" #include "content/public/common/content_switches.h" #include "content/renderer/input/input_handler_proxy_client.h" #include "content/renderer/input/input_scroll_elasticity_controller.h" #include "third_party/WebKit/public/platform/Platform.h" #include "third_party/WebKit/public/web/WebInputEvent.h" #include "ui/events/latency_info.h" #include "ui/gfx/frame_time.h" #include "ui/gfx/geometry/point_conversions.h" using blink::WebFloatPoint; using blink::WebFloatSize; using blink::WebGestureEvent; using blink::WebInputEvent; using blink::WebMouseEvent; using blink::WebMouseWheelEvent; using blink::WebPoint; using blink::WebTouchEvent; using blink::WebTouchPoint; namespace { // Maximum time between a fling event's timestamp and the first |Animate| call // for the fling curve to use the fling timestamp as the initial animation time. // Two frames allows a minor delay between event creation and the first animate. const double kMaxSecondsFromFlingTimestampToFirstAnimate = 2. / 60.; // Threshold for determining whether a fling scroll delta should have caused the // client to scroll. const float kScrollEpsilon = 0.1f; // Minimum fling velocity required for the active fling and new fling for the // two to accumulate. const double kMinBoostFlingSpeedSquare = 350. * 350.; // Minimum velocity for the active touch scroll to preserve (boost) an active // fling for which cancellation has been deferred. const double kMinBoostTouchScrollSpeedSquare = 150 * 150.; // Timeout window after which the active fling will be cancelled if no scrolls // or flings of sufficient velocity relative to the current fling are received. // The default value on Android native views is 40ms, but we use a slightly // increased value to accomodate small IPC message delays. const double kFlingBoostTimeoutDelaySeconds = 0.045; gfx::Vector2dF ToClientScrollIncrement(const WebFloatSize& increment) { return gfx::Vector2dF(-increment.width, -increment.height); } double InSecondsF(const base::TimeTicks& time) { return (time - base::TimeTicks()).InSecondsF(); } bool ShouldSuppressScrollForFlingBoosting( const gfx::Vector2dF& current_fling_velocity, const WebGestureEvent& scroll_update_event, double time_since_last_boost_event) { DCHECK_EQ(WebInputEvent::GestureScrollUpdate, scroll_update_event.type); gfx::Vector2dF dx(scroll_update_event.data.scrollUpdate.deltaX, scroll_update_event.data.scrollUpdate.deltaY); if (gfx::DotProduct(current_fling_velocity, dx) <= 0) return false; if (time_since_last_boost_event < 0.001) return true; // TODO(jdduke): Use |scroll_update_event.data.scrollUpdate.velocity{X,Y}|. // The scroll must be of sufficient velocity to maintain the active fling. const gfx::Vector2dF scroll_velocity = gfx::ScaleVector2d(dx, 1. / time_since_last_boost_event); if (scroll_velocity.LengthSquared() < kMinBoostTouchScrollSpeedSquare) return false; return true; } bool ShouldBoostFling(const gfx::Vector2dF& current_fling_velocity, const WebGestureEvent& fling_start_event) { DCHECK_EQ(WebInputEvent::GestureFlingStart, fling_start_event.type); gfx::Vector2dF new_fling_velocity( fling_start_event.data.flingStart.velocityX, fling_start_event.data.flingStart.velocityY); if (gfx::DotProduct(current_fling_velocity, new_fling_velocity) <= 0) return false; if (current_fling_velocity.LengthSquared() < kMinBoostFlingSpeedSquare) return false; if (new_fling_velocity.LengthSquared() < kMinBoostFlingSpeedSquare) return false; return true; } WebGestureEvent ObtainGestureScrollBegin(const WebGestureEvent& event) { WebGestureEvent scroll_begin_event = event; scroll_begin_event.type = WebInputEvent::GestureScrollBegin; scroll_begin_event.data.scrollBegin.deltaXHint = 0; scroll_begin_event.data.scrollBegin.deltaYHint = 0; return scroll_begin_event; } void ReportInputEventLatencyUma(const WebInputEvent& event, const ui::LatencyInfo& latency_info) { if (!(event.type == WebInputEvent::GestureScrollBegin || event.type == WebInputEvent::GestureScrollUpdate || event.type == WebInputEvent::GesturePinchBegin || event.type == WebInputEvent::GesturePinchUpdate || event.type == WebInputEvent::GestureFlingStart)) { return; } ui::LatencyInfo::LatencyMap::const_iterator it = latency_info.latency_components.find(std::make_pair( ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 0)); if (it == latency_info.latency_components.end()) return; base::TimeDelta delta = base::TimeTicks::Now() - it->second.event_time; for (size_t i = 0; i < it->second.event_count; ++i) { switch (event.type) { case blink::WebInputEvent::GestureScrollBegin: UMA_HISTOGRAM_CUSTOM_COUNTS( "Event.Latency.RendererImpl.GestureScrollBegin", delta.InMicroseconds(), 1, 1000000, 100); break; case blink::WebInputEvent::GestureScrollUpdate: UMA_HISTOGRAM_CUSTOM_COUNTS( // So named for historical reasons. "Event.Latency.RendererImpl.GestureScroll2", delta.InMicroseconds(), 1, 1000000, 100); break; case blink::WebInputEvent::GesturePinchBegin: UMA_HISTOGRAM_CUSTOM_COUNTS( "Event.Latency.RendererImpl.GesturePinchBegin", delta.InMicroseconds(), 1, 1000000, 100); break; case blink::WebInputEvent::GesturePinchUpdate: UMA_HISTOGRAM_CUSTOM_COUNTS( "Event.Latency.RendererImpl.GesturePinchUpdate", delta.InMicroseconds(), 1, 1000000, 100); break; case blink::WebInputEvent::GestureFlingStart: UMA_HISTOGRAM_CUSTOM_COUNTS( "Event.Latency.RendererImpl.GestureFlingStart", delta.InMicroseconds(), 1, 1000000, 100); break; default: NOTREACHED(); break; } } } } // namespace namespace content { InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler, InputHandlerProxyClient* client) : client_(client), input_handler_(input_handler), deferred_fling_cancel_time_seconds_(0), #ifndef NDEBUG expect_scroll_update_end_(false), #endif gesture_scroll_on_impl_thread_(false), gesture_pinch_on_impl_thread_(false), fling_may_be_active_on_main_thread_(false), disallow_horizontal_fling_scroll_(false), disallow_vertical_fling_scroll_(false), has_fling_animation_started_(false), uma_latency_reporting_enabled_(base::TimeTicks::IsHighResolution()) { DCHECK(client); input_handler_->BindToClient(this); smooth_scroll_enabled_ = base::CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableSmoothScrolling); cc::ScrollElasticityHelper* scroll_elasticity_helper = input_handler_->CreateScrollElasticityHelper(); if (scroll_elasticity_helper) { scroll_elasticity_controller_.reset( new InputScrollElasticityController(scroll_elasticity_helper)); } } InputHandlerProxy::~InputHandlerProxy() {} void InputHandlerProxy::WillShutdown() { scroll_elasticity_controller_.reset(); input_handler_ = NULL; client_->WillShutdown(); } InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEventWithLatencyInfo( const WebInputEvent& event, ui::LatencyInfo* latency_info) { DCHECK(input_handler_); if (uma_latency_reporting_enabled_) ReportInputEventLatencyUma(event, *latency_info); TRACE_EVENT_FLOW_STEP0("input,benchmark", "LatencyInfo.Flow", TRACE_ID_DONT_MANGLE(latency_info->trace_id), "HandleInputEventImpl"); scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor = input_handler_->CreateLatencyInfoSwapPromiseMonitor(latency_info); InputHandlerProxy::EventDisposition disposition = HandleInputEvent(event); return disposition; } InputHandlerProxy::EventDisposition InputHandlerProxy::HandleInputEvent( const WebInputEvent& event) { DCHECK(input_handler_); TRACE_EVENT1("input,benchmark", "InputHandlerProxy::HandleInputEvent", "type", WebInputEventTraits::GetName(event.type)); client_->DidReceiveInputEvent(event); if (FilterInputEventForFlingBoosting(event)) return DID_HANDLE; switch (event.type) { case WebInputEvent::MouseWheel: return HandleMouseWheel(static_cast<const WebMouseWheelEvent&>(event)); case WebInputEvent::GestureScrollBegin: return HandleGestureScrollBegin( static_cast<const WebGestureEvent&>(event)); case WebInputEvent::GestureScrollUpdate: return HandleGestureScrollUpdate( static_cast<const WebGestureEvent&>(event)); case WebInputEvent::GestureScrollEnd: return HandleGestureScrollEnd(static_cast<const WebGestureEvent&>(event)); case WebInputEvent::GesturePinchBegin: { DCHECK(!gesture_pinch_on_impl_thread_); const WebGestureEvent& gesture_event = static_cast<const WebGestureEvent&>(event); if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad && input_handler_->HaveWheelEventHandlersAt( gfx::Point(gesture_event.x, gesture_event.y))) { return DID_NOT_HANDLE; } else { input_handler_->PinchGestureBegin(); gesture_pinch_on_impl_thread_ = true; return DID_HANDLE; } } case WebInputEvent::GesturePinchEnd: if (gesture_pinch_on_impl_thread_) { gesture_pinch_on_impl_thread_ = false; input_handler_->PinchGestureEnd(); return DID_HANDLE; } else { return DID_NOT_HANDLE; } case WebInputEvent::GesturePinchUpdate: { if (gesture_pinch_on_impl_thread_) { const WebGestureEvent& gesture_event = static_cast<const WebGestureEvent&>(event); if (gesture_event.data.pinchUpdate.zoomDisabled) return DROP_EVENT; input_handler_->PinchGestureUpdate( gesture_event.data.pinchUpdate.scale, gfx::Point(gesture_event.x, gesture_event.y)); return DID_HANDLE; } else { return DID_NOT_HANDLE; } } case WebInputEvent::GestureFlingStart: return HandleGestureFlingStart( *static_cast<const WebGestureEvent*>(&event)); case WebInputEvent::GestureFlingCancel: if (CancelCurrentFling()) return DID_HANDLE; else if (!fling_may_be_active_on_main_thread_) return DROP_EVENT; return DID_NOT_HANDLE; case WebInputEvent::TouchStart: return HandleTouchStart(static_cast<const WebTouchEvent&>(event)); case WebInputEvent::MouseMove: { const WebMouseEvent& mouse_event = static_cast<const WebMouseEvent&>(event); // TODO(tony): Ignore when mouse buttons are down? // TODO(davemoore): This should never happen, but bug #326635 showed some // surprising crashes. CHECK(input_handler_); input_handler_->MouseMoveAt(gfx::Point(mouse_event.x, mouse_event.y)); return DID_NOT_HANDLE; } default: if (WebInputEvent::isKeyboardEventType(event.type)) { // Only call |CancelCurrentFling()| if a fling was active, as it will // otherwise disrupt an in-progress touch scroll. if (fling_curve_) CancelCurrentFling(); } break; } return DID_NOT_HANDLE; } InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel( const WebMouseWheelEvent& wheel_event) { InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE; cc::InputHandlerScrollResult scroll_result; // TODO(ccameron): The rail information should be pushed down into // InputHandler. gfx::Vector2dF scroll_delta( wheel_event.railsMode != WebInputEvent::RailsModeVertical ? -wheel_event.deltaX : 0, wheel_event.railsMode != WebInputEvent::RailsModeHorizontal ? -wheel_event.deltaY : 0); if (wheel_event.scrollByPage) { // TODO(jamesr): We don't properly handle scroll by page in the compositor // thread, so punt it to the main thread. http://crbug.com/236639 result = DID_NOT_HANDLE; } else if (!wheel_event.canScroll) { // Wheel events with |canScroll| == false will not trigger scrolling, // only event handlers. Forward to the main thread. result = DID_NOT_HANDLE; } else if (smooth_scroll_enabled_) { cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollAnimated(gfx::Point(wheel_event.x, wheel_event.y), scroll_delta); switch (scroll_status) { case cc::InputHandler::SCROLL_STARTED: result = DID_HANDLE; break; case cc::InputHandler::SCROLL_IGNORED: result = DROP_EVENT; default: result = DID_NOT_HANDLE; break; } } else { cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( gfx::Point(wheel_event.x, wheel_event.y), cc::InputHandler::WHEEL); switch (scroll_status) { case cc::InputHandler::SCROLL_STARTED: { TRACE_EVENT_INSTANT2("input", "InputHandlerProxy::handle_input wheel scroll", TRACE_EVENT_SCOPE_THREAD, "deltaX", scroll_delta.x(), "deltaY", scroll_delta.y()); gfx::Point scroll_point(wheel_event.x, wheel_event.y); scroll_result = input_handler_->ScrollBy(scroll_point, scroll_delta); HandleOverscroll(scroll_point, scroll_result); input_handler_->ScrollEnd(); result = scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT; break; } case cc::InputHandler::SCROLL_IGNORED: // TODO(jamesr): This should be DROP_EVENT, but in cases where we fail // to properly sync scrollability it's safer to send the event to the // main thread. Change back to DROP_EVENT once we have synchronization // bugs sorted out. result = DID_NOT_HANDLE; break; case cc::InputHandler::SCROLL_UNKNOWN: case cc::InputHandler::SCROLL_ON_MAIN_THREAD: result = DID_NOT_HANDLE; break; case cc::InputHandler::ScrollStatusCount: NOTREACHED(); break; } } // Send the event and its disposition to the elasticity controller to update // the over-scroll animation. If the event is to be handled on the main // thread, the event and its disposition will be sent to the elasticity // controller after being handled on the main thread. if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE) { // Note that the call to the elasticity controller is made asynchronously, // to minimize divergence between main thread and impl thread event // handling paths. base::MessageLoop::current()->PostTask( FROM_HERE, base::Bind(&InputScrollElasticityController::ObserveWheelEventAndResult, scroll_elasticity_controller_->GetWeakPtr(), wheel_event, scroll_result)); } return result; } InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollBegin( const WebGestureEvent& gesture_event) { DCHECK(!gesture_scroll_on_impl_thread_); #ifndef NDEBUG DCHECK(!expect_scroll_update_end_); expect_scroll_update_end_ = true; #endif cc::InputHandler::ScrollStatus scroll_status = input_handler_->ScrollBegin( gfx::Point(gesture_event.x, gesture_event.y), cc::InputHandler::GESTURE); UMA_HISTOGRAM_ENUMERATION("Renderer4.CompositorScrollHitTestResult", scroll_status, cc::InputHandler::ScrollStatusCount); switch (scroll_status) { case cc::InputHandler::SCROLL_STARTED: TRACE_EVENT_INSTANT0("input", "InputHandlerProxy::handle_input gesture scroll", TRACE_EVENT_SCOPE_THREAD); gesture_scroll_on_impl_thread_ = true; return DID_HANDLE; case cc::InputHandler::SCROLL_UNKNOWN: case cc::InputHandler::SCROLL_ON_MAIN_THREAD: return DID_NOT_HANDLE; case cc::InputHandler::SCROLL_IGNORED: return DROP_EVENT; case cc::InputHandler::ScrollStatusCount: NOTREACHED(); break; } return DID_NOT_HANDLE; } InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollUpdate( const WebGestureEvent& gesture_event) { #ifndef NDEBUG DCHECK(expect_scroll_update_end_); #endif if (!gesture_scroll_on_impl_thread_ && !gesture_pinch_on_impl_thread_) return DID_NOT_HANDLE; gfx::Point scroll_point(gesture_event.x, gesture_event.y); gfx::Vector2dF scroll_delta(-gesture_event.data.scrollUpdate.deltaX, -gesture_event.data.scrollUpdate.deltaY); cc::InputHandlerScrollResult scroll_result = input_handler_->ScrollBy( scroll_point, scroll_delta); HandleOverscroll(scroll_point, scroll_result); return scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT; } InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd( const WebGestureEvent& gesture_event) { #ifndef NDEBUG DCHECK(expect_scroll_update_end_); expect_scroll_update_end_ = false; #endif input_handler_->ScrollEnd(); if (!gesture_scroll_on_impl_thread_) return DID_NOT_HANDLE; gesture_scroll_on_impl_thread_ = false; return DID_HANDLE; } InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureFlingStart( const WebGestureEvent& gesture_event) { cc::InputHandler::ScrollStatus scroll_status; if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { scroll_status = input_handler_->ScrollBegin( gfx::Point(gesture_event.x, gesture_event.y), cc::InputHandler::NON_BUBBLING_GESTURE); } else { if (!gesture_scroll_on_impl_thread_) scroll_status = cc::InputHandler::SCROLL_ON_MAIN_THREAD; else scroll_status = input_handler_->FlingScrollBegin(); } #ifndef NDEBUG expect_scroll_update_end_ = false; #endif switch (scroll_status) { case cc::InputHandler::SCROLL_STARTED: { if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) input_handler_->ScrollEnd(); const float vx = gesture_event.data.flingStart.velocityX; const float vy = gesture_event.data.flingStart.velocityY; current_fling_velocity_ = gfx::Vector2dF(vx, vy); DCHECK(!current_fling_velocity_.IsZero()); fling_curve_.reset(client_->CreateFlingAnimationCurve( gesture_event.sourceDevice, WebFloatPoint(vx, vy), blink::WebSize())); disallow_horizontal_fling_scroll_ = !vx; disallow_vertical_fling_scroll_ = !vy; TRACE_EVENT_ASYNC_BEGIN2("input", "InputHandlerProxy::HandleGestureFling::started", this, "vx", vx, "vy", vy); // Note that the timestamp will only be used to kickstart the animation if // its sufficiently close to the timestamp of the first call |Animate()|. has_fling_animation_started_ = false; fling_parameters_.startTime = gesture_event.timeStampSeconds; fling_parameters_.delta = WebFloatPoint(vx, vy); fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); fling_parameters_.globalPoint = WebPoint(gesture_event.globalX, gesture_event.globalY); fling_parameters_.modifiers = gesture_event.modifiers; fling_parameters_.sourceDevice = gesture_event.sourceDevice; input_handler_->SetNeedsAnimate(); return DID_HANDLE; } case cc::InputHandler::SCROLL_UNKNOWN: case cc::InputHandler::SCROLL_ON_MAIN_THREAD: { TRACE_EVENT_INSTANT0("input", "InputHandlerProxy::HandleGestureFling::" "scroll_on_main_thread", TRACE_EVENT_SCOPE_THREAD); gesture_scroll_on_impl_thread_ = false; fling_may_be_active_on_main_thread_ = true; return DID_NOT_HANDLE; } case cc::InputHandler::SCROLL_IGNORED: { TRACE_EVENT_INSTANT0( "input", "InputHandlerProxy::HandleGestureFling::ignored", TRACE_EVENT_SCOPE_THREAD); gesture_scroll_on_impl_thread_ = false; if (gesture_event.sourceDevice == blink::WebGestureDeviceTouchpad) { // We still pass the curve to the main thread if there's nothing // scrollable, in case something // registers a handler before the curve is over. return DID_NOT_HANDLE; } return DROP_EVENT; } case cc::InputHandler::ScrollStatusCount: NOTREACHED(); break; } return DID_NOT_HANDLE; } InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchStart( const blink::WebTouchEvent& touch_event) { for (size_t i = 0; i < touch_event.touchesLength; ++i) { if (touch_event.touches[i].state != WebTouchPoint::StatePressed) continue; if (input_handler_->DoTouchEventsBlockScrollAt( gfx::Point(touch_event.touches[i].position.x, touch_event.touches[i].position.y))) { // TODO(rbyers): We should consider still sending the touch events to // main asynchronously (crbug.com/455539). return DID_NOT_HANDLE; } } return DROP_EVENT; } bool InputHandlerProxy::FilterInputEventForFlingBoosting( const WebInputEvent& event) { if (!WebInputEvent::isGestureEventType(event.type)) return false; if (!fling_curve_) { DCHECK(!deferred_fling_cancel_time_seconds_); return false; } const WebGestureEvent& gesture_event = static_cast<const WebGestureEvent&>(event); if (gesture_event.type == WebInputEvent::GestureFlingCancel) { if (gesture_event.data.flingCancel.preventBoosting) return false; if (current_fling_velocity_.LengthSquared() < kMinBoostFlingSpeedSquare) return false; TRACE_EVENT_INSTANT0("input", "InputHandlerProxy::FlingBoostStart", TRACE_EVENT_SCOPE_THREAD); deferred_fling_cancel_time_seconds_ = event.timeStampSeconds + kFlingBoostTimeoutDelaySeconds; return true; } // A fling is either inactive or is "free spinning", i.e., has yet to be // interrupted by a touch gesture, in which case there is nothing to filter. if (!deferred_fling_cancel_time_seconds_) return false; // Gestures from a different source should immediately interrupt the fling. if (gesture_event.sourceDevice != fling_parameters_.sourceDevice) { CancelCurrentFling(); return false; } switch (gesture_event.type) { case WebInputEvent::GestureTapCancel: case WebInputEvent::GestureTapDown: return false; case WebInputEvent::GestureScrollBegin: if (!input_handler_->IsCurrentlyScrollingLayerAt( gfx::Point(gesture_event.x, gesture_event.y), fling_parameters_.sourceDevice == blink::WebGestureDeviceTouchpad ? cc::InputHandler::NON_BUBBLING_GESTURE : cc::InputHandler::GESTURE)) { CancelCurrentFling(); return false; } // TODO(jdduke): Use |gesture_event.data.scrollBegin.delta{X,Y}Hint| to // determine if the ScrollBegin should immediately cancel the fling. ExtendBoostedFlingTimeout(gesture_event); return true; case WebInputEvent::GestureScrollUpdate: { const double time_since_last_boost_event = event.timeStampSeconds - last_fling_boost_event_.timeStampSeconds; if (ShouldSuppressScrollForFlingBoosting(current_fling_velocity_, gesture_event, time_since_last_boost_event)) { ExtendBoostedFlingTimeout(gesture_event); return true; } CancelCurrentFling(); return false; } case WebInputEvent::GestureScrollEnd: // Clear the last fling boost event *prior* to fling cancellation, // preventing insertion of a synthetic GestureScrollBegin. last_fling_boost_event_ = WebGestureEvent(); CancelCurrentFling(); return true; case WebInputEvent::GestureFlingStart: { DCHECK_EQ(fling_parameters_.sourceDevice, gesture_event.sourceDevice); bool fling_boosted = fling_parameters_.modifiers == gesture_event.modifiers && ShouldBoostFling(current_fling_velocity_, gesture_event); gfx::Vector2dF new_fling_velocity( gesture_event.data.flingStart.velocityX, gesture_event.data.flingStart.velocityY); DCHECK(!new_fling_velocity.IsZero()); if (fling_boosted) current_fling_velocity_ += new_fling_velocity; else current_fling_velocity_ = new_fling_velocity; WebFloatPoint velocity(current_fling_velocity_.x(), current_fling_velocity_.y()); deferred_fling_cancel_time_seconds_ = 0; disallow_horizontal_fling_scroll_ = !velocity.x; disallow_vertical_fling_scroll_ = !velocity.y; last_fling_boost_event_ = WebGestureEvent(); fling_curve_.reset(client_->CreateFlingAnimationCurve( gesture_event.sourceDevice, velocity, blink::WebSize())); fling_parameters_.startTime = gesture_event.timeStampSeconds; fling_parameters_.delta = velocity; fling_parameters_.point = WebPoint(gesture_event.x, gesture_event.y); fling_parameters_.globalPoint = WebPoint(gesture_event.globalX, gesture_event.globalY); TRACE_EVENT_INSTANT2("input", fling_boosted ? "InputHandlerProxy::FlingBoosted" : "InputHandlerProxy::FlingReplaced", TRACE_EVENT_SCOPE_THREAD, "vx", current_fling_velocity_.x(), "vy", current_fling_velocity_.y()); // The client expects balanced calls between a consumed GestureFlingStart // and |DidStopFlinging()|. TODO(jdduke): Provide a count parameter to // |DidStopFlinging()| and only send after the accumulated fling ends. client_->DidStopFlinging(); return true; } default: // All other types of gestures (taps, presses, etc...) will complete the // deferred fling cancellation. CancelCurrentFling(); return false; } } void InputHandlerProxy::ExtendBoostedFlingTimeout( const blink::WebGestureEvent& event) { TRACE_EVENT_INSTANT0("input", "InputHandlerProxy::ExtendBoostedFlingTimeout", TRACE_EVENT_SCOPE_THREAD); deferred_fling_cancel_time_seconds_ = event.timeStampSeconds + kFlingBoostTimeoutDelaySeconds; last_fling_boost_event_ = event; } void InputHandlerProxy::Animate(base::TimeTicks time) { if (scroll_elasticity_controller_) scroll_elasticity_controller_->Animate(time); if (!fling_curve_) return; double monotonic_time_sec = InSecondsF(time); if (deferred_fling_cancel_time_seconds_ && monotonic_time_sec > deferred_fling_cancel_time_seconds_) { CancelCurrentFling(); return; } client_->DidAnimateForInput(); if (!has_fling_animation_started_) { has_fling_animation_started_ = true; // Guard against invalid, future or sufficiently stale start times, as there // are no guarantees fling event and animation timestamps are compatible. if (!fling_parameters_.startTime || monotonic_time_sec <= fling_parameters_.startTime || monotonic_time_sec >= fling_parameters_.startTime + kMaxSecondsFromFlingTimestampToFirstAnimate) { fling_parameters_.startTime = monotonic_time_sec; input_handler_->SetNeedsAnimate(); return; } } bool fling_is_active = fling_curve_->apply(monotonic_time_sec - fling_parameters_.startTime, this); if (disallow_vertical_fling_scroll_ && disallow_horizontal_fling_scroll_) fling_is_active = false; if (fling_is_active) { input_handler_->SetNeedsAnimate(); } else { TRACE_EVENT_INSTANT0("input", "InputHandlerProxy::animate::flingOver", TRACE_EVENT_SCOPE_THREAD); CancelCurrentFling(); } } void InputHandlerProxy::MainThreadHasStoppedFlinging() { fling_may_be_active_on_main_thread_ = false; client_->DidStopFlinging(); } void InputHandlerProxy::ReconcileElasticOverscrollAndRootScroll() { if (scroll_elasticity_controller_) scroll_elasticity_controller_->ReconcileStretchAndScroll(); } void InputHandlerProxy::HandleOverscroll( const gfx::Point& causal_event_viewport_point, const cc::InputHandlerScrollResult& scroll_result) { DCHECK(client_); if (!scroll_result.did_overscroll_root) return; TRACE_EVENT2("input", "InputHandlerProxy::DidOverscroll", "dx", scroll_result.unused_scroll_delta.x(), "dy", scroll_result.unused_scroll_delta.y()); DidOverscrollParams params; params.accumulated_overscroll = scroll_result.accumulated_root_overscroll; params.latest_overscroll_delta = scroll_result.unused_scroll_delta; params.current_fling_velocity = ToClientScrollIncrement(current_fling_velocity_); params.causal_event_viewport_point = causal_event_viewport_point; if (fling_curve_) { static const int kFlingOverscrollThreshold = 1; disallow_horizontal_fling_scroll_ |= std::abs(params.accumulated_overscroll.x()) >= kFlingOverscrollThreshold; disallow_vertical_fling_scroll_ |= std::abs(params.accumulated_overscroll.y()) >= kFlingOverscrollThreshold; } client_->DidOverscroll(params); } bool InputHandlerProxy::CancelCurrentFling() { if (CancelCurrentFlingWithoutNotifyingClient()) { client_->DidStopFlinging(); return true; } return false; } bool InputHandlerProxy::CancelCurrentFlingWithoutNotifyingClient() { bool had_fling_animation = fling_curve_; if (had_fling_animation && fling_parameters_.sourceDevice == blink::WebGestureDeviceTouchscreen) { input_handler_->ScrollEnd(); TRACE_EVENT_ASYNC_END0( "input", "InputHandlerProxy::HandleGestureFling::started", this); } TRACE_EVENT_INSTANT1("input", "InputHandlerProxy::CancelCurrentFling", TRACE_EVENT_SCOPE_THREAD, "had_fling_animation", had_fling_animation); fling_curve_.reset(); has_fling_animation_started_ = false; gesture_scroll_on_impl_thread_ = false; current_fling_velocity_ = gfx::Vector2dF(); fling_parameters_ = blink::WebActiveWheelFlingParameters(); if (deferred_fling_cancel_time_seconds_) { deferred_fling_cancel_time_seconds_ = 0; WebGestureEvent last_fling_boost_event = last_fling_boost_event_; last_fling_boost_event_ = WebGestureEvent(); if (last_fling_boost_event.type == WebInputEvent::GestureScrollBegin || last_fling_boost_event.type == WebInputEvent::GestureScrollUpdate) { // Synthesize a GestureScrollBegin, as the original was suppressed. HandleInputEvent(ObtainGestureScrollBegin(last_fling_boost_event)); } } return had_fling_animation; } bool InputHandlerProxy::TouchpadFlingScroll( const WebFloatSize& increment) { WebMouseWheelEvent synthetic_wheel; synthetic_wheel.type = WebInputEvent::MouseWheel; synthetic_wheel.deltaX = increment.width; synthetic_wheel.deltaY = increment.height; synthetic_wheel.hasPreciseScrollingDeltas = true; synthetic_wheel.x = fling_parameters_.point.x; synthetic_wheel.y = fling_parameters_.point.y; synthetic_wheel.globalX = fling_parameters_.globalPoint.x; synthetic_wheel.globalY = fling_parameters_.globalPoint.y; synthetic_wheel.modifiers = fling_parameters_.modifiers; InputHandlerProxy::EventDisposition disposition = HandleInputEvent(synthetic_wheel); switch (disposition) { case DID_HANDLE: return true; case DROP_EVENT: break; case DID_NOT_HANDLE: TRACE_EVENT_INSTANT0("input", "InputHandlerProxy::scrollBy::AbortFling", TRACE_EVENT_SCOPE_THREAD); // If we got a DID_NOT_HANDLE, that means we need to deliver wheels on the // main thread. In this case we need to schedule a commit and transfer the // fling curve over to the main thread and run the rest of the wheels from // there. This can happen when flinging a page that contains a scrollable // subarea that we can't scroll on the thread if the fling starts outside // the subarea but then is flung "under" the pointer. client_->TransferActiveWheelFlingAnimation(fling_parameters_); fling_may_be_active_on_main_thread_ = true; CancelCurrentFlingWithoutNotifyingClient(); break; } return false; } bool InputHandlerProxy::scrollBy(const WebFloatSize& increment, const WebFloatSize& velocity) { WebFloatSize clipped_increment; WebFloatSize clipped_velocity; if (!disallow_horizontal_fling_scroll_) { clipped_increment.width = increment.width; clipped_velocity.width = velocity.width; } if (!disallow_vertical_fling_scroll_) { clipped_increment.height = increment.height; clipped_velocity.height = velocity.height; } current_fling_velocity_ = clipped_velocity; // Early out if the increment is zero, but avoid early terimination if the // velocity is still non-zero. if (clipped_increment == WebFloatSize()) return clipped_velocity != WebFloatSize(); TRACE_EVENT2("input", "InputHandlerProxy::scrollBy", "x", clipped_increment.width, "y", clipped_increment.height); bool did_scroll = false; switch (fling_parameters_.sourceDevice) { case blink::WebGestureDeviceTouchpad: did_scroll = TouchpadFlingScroll(clipped_increment); break; case blink::WebGestureDeviceTouchscreen: { clipped_increment = ToClientScrollIncrement(clipped_increment); cc::InputHandlerScrollResult scroll_result = input_handler_->ScrollBy( fling_parameters_.point, clipped_increment); HandleOverscroll(fling_parameters_.point, scroll_result); did_scroll = scroll_result.did_scroll; } break; } if (did_scroll) { fling_parameters_.cumulativeScroll.width += clipped_increment.width; fling_parameters_.cumulativeScroll.height += clipped_increment.height; } // It's possible the provided |increment| is sufficiently small as to not // trigger a scroll, e.g., with a trivial time delta between fling updates. // Return true in this case to prevent early fling termination. if (std::abs(clipped_increment.width) < kScrollEpsilon && std::abs(clipped_increment.height) < kScrollEpsilon) return true; return did_scroll; } } // namespace content
bsd-3-clause
jlblancoc/suitesparse-metis-for-windows
SuiteSparse/GraphBLAS/Source/Generated/GB_AxB__eq_eq_int64.c
8246
//------------------------------------------------------------------------------ // GB_AxB: hard-coded C=A*B and C<M>=A*B //------------------------------------------------------------------------------ // SuiteSparse:GraphBLAS, Timothy A. Davis, (c) 2017-2018, All Rights Reserved. // http://suitesparse.com See GraphBLAS/Doc/License.txt for license. // If this filename has a double underscore in its name ("__") then it has been // automatically constructed from Generator/GB_AxB.c, via the Source/axb*.m // scripts, and should not be editted. Edit the original source file instead. //------------------------------------------------------------------------------ #include "GB.h" #ifndef GBCOMPACT #include "GB_heap.h" #include "GB_AxB__semirings.h" // The C=A*B semiring is defined by the following types and operators: // A*B function (Gustavon): GB_AgusB__eq_eq_int64 // A'*B function (dot): GB_AdotB__eq_eq_int64 // A*B function (heap): GB_AheapB__eq_eq_int64 // Z type: bool (the type of C) // X type: int64_t (the type of x for z=mult(x,y)) // Y type: int64_t (the type of y for z=mult(x,y)) // handle flipxy: 0 (0 if mult(x,y) is commutative, 1 otherwise) // Identity: true (where cij = (cij == identity) does not change cij) // Multiply: z = x == y // Add: cij = (cij == z) #define GB_XTYPE \ int64_t #define GB_YTYPE \ int64_t #define GB_HANDLE_FLIPXY \ 0 #define GB_MULTOP(z,x,y) \ z = x == y //------------------------------------------------------------------------------ // C<M>=A*B and C=A*B: gather/scatter saxpy-based method (Gustavson) //------------------------------------------------------------------------------ #define GB_IDENTITY \ true // x [i] = y #define GB_COPY_SCALAR_TO_ARRAY(x,i,y,s) \ x [i] = y ; // x = y [i] #define GB_COPY_ARRAY_TO_SCALAR(x,y,i,s) \ GB_btype x = y [i] ; // x [i] = y [i] #define GB_COPY_ARRAY_TO_ARRAY(x,i,y,j,s) \ x [i] = y [j] ; // mult-add operation (no mask) #define GB_MULTADD_NOMASK \ { \ /* Sauna_Work [i] += A(i,k) * B(k,j) */ \ GB_atype aik = Ax [pA] ; \ bool t ; \ GB_MULTIPLY (t, aik, bkj) ; \ Sauna_Work [i] = (Sauna_Work [i] == t) ; \ } // mult-add operation (with mask) #define GB_MULTADD_WITH_MASK \ { \ /* Sauna_Work [i] += A(i,k) * B(k,j) */ \ GB_atype aik = Ax [pA] ; \ bool t ; \ GB_MULTIPLY (t, aik, bkj) ; \ if (mark == hiwater) \ { \ /* first time C(i,j) seen */ \ Sauna_Mark [i] = hiwater + 1 ; \ Sauna_Work [i] = t ; \ } \ else \ { \ /* C(i,j) seen before, update it */ \ Sauna_Work [i] = (Sauna_Work [i] == t) ; \ } \ } GrB_Info GB_AgusB__eq_eq_int64 ( GrB_Matrix C, const GrB_Matrix M, const GrB_Matrix A, const GrB_Matrix B, bool flipxy, // if true, A and B have been swapped GB_Sauna Sauna, // sparse accumulator GB_Context Context ) { bool *restrict Sauna_Work = Sauna->Sauna_Work ; // size C->vlen*zsize bool *restrict Cx = C->x ; GrB_Info info = GrB_SUCCESS ; #include "GB_AxB_Gustavson_flipxy.c" return (info) ; } //------------------------------------------------------------------------------ // C<M>=A'*B or C=A'*B: dot product //------------------------------------------------------------------------------ // get A(k,i) #define GB_DOT_GETA(pA) \ GB_atype aki = Ax [pA] ; // get B(k,j) #define GB_DOT_GETB(pB) \ GB_btype bkj = Bx [pB] ; // t = aki*bkj #define GB_DOT_MULT(bkj) \ bool t ; \ GB_MULTIPLY (t, aki, bkj) ; // cij += t #define GB_DOT_ADD \ cij = (cij == t) ; // cij = t #define GB_DOT_COPY \ cij = t ; // cij is not a pointer but a scalar; nothing to do #define GB_DOT_REACQUIRE ; // clear cij #define GB_DOT_CLEAR \ cij = true ; // save the value of C(i,j) #define GB_DOT_SAVE \ Cx [cnz] = cij ; #define GB_DOT_WORK_TYPE \ GB_btype #define GB_DOT_WORK(k) Work [k] // Work [k] = Bx [pB] #define GB_DOT_SCATTER \ Work [k] = Bx [pB] ; GrB_Info GB_AdotB__eq_eq_int64 ( GrB_Matrix *Chandle, const GrB_Matrix M, const GrB_Matrix A, const GrB_Matrix B, bool flipxy, // if true, A and B have been swapped GB_Context Context ) { GrB_Matrix C = (*Chandle) ; bool *restrict Cx = C->x ; bool cij ; GrB_Info info = GrB_SUCCESS ; size_t bkj_size = B->type->size ; // no typecasting here #include "GB_AxB_dot_flipxy.c" return (info) ; } //------------------------------------------------------------------------------ // C<M>=A*B and C=A*B: heap saxpy-based method //------------------------------------------------------------------------------ #define GB_CIJ_GETB(pB) \ GB_btype bkj = Bx [pB] ; // C(i,j) = A(i,k) * bkj #define GB_CIJ_MULT(pA) \ { \ GB_atype aik = Ax [pA] ; \ GB_MULTIPLY (cij, aik, bkj) ; \ } // C(i,j) += A(i,k) * B(k,j) #define GB_CIJ_MULTADD(pA,pB) \ { \ GB_atype aik = Ax [pA] ; \ GB_btype bkj = Bx [pB] ; \ bool t ; \ GB_MULTIPLY (t, aik, bkj) ; \ cij = (cij == t) ; \ } // cij is not a pointer but a scalar; nothing to do #define GB_CIJ_REACQUIRE ; // cij = identity #define GB_CIJ_CLEAR \ cij = true ; // save the value of C(i,j) #define GB_CIJ_SAVE \ Cx [cnz] = cij ; GrB_Info GB_AheapB__eq_eq_int64 ( GrB_Matrix *Chandle, const GrB_Matrix M, const GrB_Matrix A, const GrB_Matrix B, bool flipxy, // if true, A and B have been swapped int64_t *restrict List, GB_pointer_pair *restrict pA_pair, GB_Element *restrict Heap, const int64_t bjnz_max, GB_Context Context ) { GrB_Matrix C = (*Chandle) ; bool *restrict Cx = C->x ; bool cij ; int64_t cvlen = C->vlen ; GrB_Info info = GrB_SUCCESS ; GB_CIJ_CLEAR ; #include "GB_AxB_heap_flipxy.c" return (info) ; } //------------------------------------------------------------------------------ // clear macro definitions //------------------------------------------------------------------------------ #undef GB_XTYPE #undef GB_YTYPE #undef GB_HANDLE_FLIPXY #undef GB_MULTOP #undef GB_IDENTITY #undef GB_COPY_SCALAR_TO_ARRAY #undef GB_COPY_ARRAY_TO_SCALAR #undef GB_COPY_ARRAY_TO_ARRAY #undef GB_MULTADD_NOMASK #undef GB_MULTADD_WITH_MASK #undef GB_DOT_GETA #undef GB_DOT_GETB #undef GB_DOT_MULT #undef GB_DOT_ADD #undef GB_DOT_COPY #undef GB_DOT_REACQUIRE #undef GB_DOT_CLEAR #undef GB_DOT_SAVE #undef GB_DOT_WORK_TYPE #undef GB_DOT_WORK #undef GB_DOT_SCATTER #undef GB_CIJ_GETB #undef GB_CIJ_MULT #undef GB_CIJ_MULTADD #undef GB_CIJ_REACQUIRE #undef GB_CIJ_CLEAR #undef GB_CIJ_SAVE #undef GB_MULTIPLY #endif
bsd-3-clause
NCIP/cananolab
docs/webappOnlineHelp/popups/caNanoLab_Glossary-1077108.html
3019
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <!-- MOTW-DISABLED saved from url=(0014)about:internet --> <title>caNanoLab_Glossary-1077108.html</title> <link rel="StyleSheet" href="../css/caNanoLab_Glossary.css" type="text/css" media="all" /> <link rel="StyleSheet" href="../css/webworks.css" type="text/css" media="all" /> <script type="text/javascript" language="JavaScript1.2" src="../wwhdata/common/context.js"></script> <script type="text/javascript" language="JavaScript1.2" src="../wwhdata/common/towwhdir.js"></script> <script type="text/javascript" language="JavaScript1.2" src="../wwhdata/common/wwhpagef.js"></script> <script type="text/javascript" language="JavaScript1.2"> <!-- var WebWorksRootPath = "../"; // --> </script> <script type="text/javascript" language="JavaScript1.2"> <!-- // Set reference to top level help frame // var WWHFrame = WWHGetWWHFrame("../", false); // --> </script> <script type="text/javascript" language="JavaScript1.2" src="../scripts/expand.js"></script> </head> <body style="background-color: #FFFFCC; cursor: pointer; cursor: hand; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-left: 6px; padding-right: 6px; padding-top: 6px; width: 250px;" onLoad="WWHUpdate();" onUnload="WWHUnload();" onKeyDown="WWHHandleKeyDown((document.all||document.getElementById||document.layers)?event:null);" onKeyPress="WWHHandleKeyPress((document.all||document.getElementById||document.layers)?event:null);" onKeyUp="WWHHandleKeyUp((document.all||document.getElementById||document.layers)?event:null);"> <div class="Popup_Text"><a name="1077108">The interaction with virus-infected or transformed cells by </a>diverse adhesion or co-stimulatory molecules and release of cytokines, chemokines, and lethal chemicals from granules.</div> <script type="text/javascript" language="JavaScript1.2"> <!-- if ((WWHFrame != null) && ( ! WWHFrame.WWHBrowser.mbSupportsPopups) && ( ! WWHFrame.WWHBrowser.mbSupportsIFrames)) { document.writeln("<div><a href=\"javascript:WWHFrame.WWHHelp.fDisplayFile('caNanoLab', 'caNanoLab_Glossary.9.1.html#1077108');\">" + WWHFrame.WWHHelp.fEscapeHTML(WWHFrame.WWHHelp.mMessages.mAccessibilityPopupClickThrough) + "</a></div>"); } // --> </script> <script type="text/javascript" language="JavaScript1.2"> <!-- document.write(WWHRelatedTopicsDivTag() + WWHPopupDivTag() + WWHALinksDivTag()); // --> </script> </body> </html>
bsd-3-clause
oswen244/proserpaz
models/AuxiliosSearch.php
3499
<?php namespace app\models; use Yii; use yii\base\Model; use yii\data\ActiveDataProvider; use app\models\Auxilios; /** * AuxiliosSearch represents the model behind the search form about `app\models\Auxilios`. */ class AuxiliosSearch extends Auxilios { public $documento_cliente; public $nombre_cliente; public $apellido_cliente; public $tipoAuxilio; public $familiar; /** * @inheritdoc */ public function rules() { return [ [['id_auxilio', 'tipo', 'num_meses', 'estado', 'id_cliente', 'tipo_auxilio', 'id_familiar'], 'integer'], [['porcentaje_aux', 'monto'], 'number'], [['fecha_auxilio', 'proveedor'], 'safe'], [['documento_cliente', 'nombre_cliente', 'apellido_cliente', 'tipoAuxilio'], 'safe'], ]; } /** * @inheritdoc */ public function scenarios() { // bypass scenarios() implementation in the parent class return Model::scenarios(); } /** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params,$tipo, $id) { if($id == 0){ $query = Auxilios::find()->where('auxilios.tipo=:tipo'); }else{ $query = Auxilios::find()->where('auxilios.tipo=:tipo AND auxilios.id_cliente =:id'); $query->addParams([':id' => $id]); } $query->addParams([':tipo' => $tipo]); $query->joinWith(['idCliente', 'idFamiliar', 'tipoAuxilio']); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $dataProvider->sort->attributes['documento_cliente'] =[ 'asc'=>['clientes.num_id'=>SORT_ASC], 'desc'=>['clientes.num_id'=>SORT_DESC], ]; $dataProvider->sort->attributes['nombre_cliente'] =[ 'asc'=>['clientes.nombres'=>SORT_ASC], 'desc'=>['clientes.nombres'=>SORT_DESC], ]; $dataProvider->sort->attributes['apellido_cliente'] =[ 'asc'=>['clientes.apellidos'=>SORT_ASC], 'desc'=>['clientes.apellidos'=>SORT_DESC], ]; $dataProvider->sort->attributes['tipoAuxilio'] =[ 'asc'=>['tipo_auxilio.tipo_auxilio'=>SORT_ASC], 'desc'=>['tipo_auxilio.tipo_auxilio'=>SORT_DESC], ]; if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere([ 'id_auxilio' => $this->id_auxilio, 'tipo' => $this->tipo, 'porcentaje_aux' => $this->porcentaje_aux, 'monto' => $this->monto, 'num_meses' => $this->num_meses, 'fecha_auxilio' => $this->fecha_auxilio, 'estado' => $this->estado, 'id_cliente' => $this->id_cliente, 'tipo_auxilio' => $this->tipo_auxilio, 'id_familiar' => $this->id_familiar, ]); $query->andFilterWhere(['like', 'proveedor', $this->proveedor]); $query->andFilterWhere(['like', 'clientes.num_id', $this->documento_cliente]); $query->andFilterWhere(['like', 'clientes.nombres', $this->nombre_cliente]); $query->andFilterWhere(['like', 'clientes.apellidos', $this->apellido_cliente]); $query->andFilterWhere(['like', 'tipo_auxilio.tipo_auxilio', $this->tipoAuxilio]); return $dataProvider; } }
bsd-3-clause
ebragge/LibAudio
LibAudio/ToneSampleGenerator.h
1297
//********************************************************* // // Copyright (c) Microsoft. All rights reserved. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //********************************************************* // // ToneSampleGenerator.h // #pragma once #define _USE_MATH_DEFINES #include <math.h> #include <limits.h> #include "Common.h" template<typename T> T Convert(double Value); namespace LibAudio { class ToneSampleGenerator { public: ToneSampleGenerator(); ~ToneSampleGenerator(); Platform::Boolean IsEOF(){ return (m_SampleQueue == nullptr); }; UINT32 GetBufferLength(){ return (m_SampleQueue != nullptr ? m_SampleQueue->BufferSize : 0 ); }; void Flush(); HRESULT GenerateSampleBuffer(DWORD Frequency, UINT32 FramesPerPeriod, WAVEFORMATEX *wfx); HRESULT FillSampleBuffer(UINT32 BytesToRead, BYTE *Data); private: template <typename T> void GenerateSineSamples(BYTE *Buffer, size_t BufferLength, DWORD Frequency, WORD ChannelCount, DWORD SamplesPerSecond, double Amplitude, double *InitialTheta); private: RenderBuffer *m_SampleQueue; RenderBuffer **m_SampleQueueTail; }; }
bsd-3-clause
faouellet/System16
README.md
1022
**Emulator for the Chip16** ============== [![Build Status](https://travis-ci.org/faouellet/System16.svg?branch=master)](https://travis-ci.org/faouellet/System16) For Windows users: -------------- You will need CMake in order to create the Visual Studio solution. You can get it at http://www.cmake.org/cmake/resources/software.html How to: - 1- Start CMake (cmake-gui) - 2- Specify the path to the source code - 3- Specify the path where you want the solution to be created. (I suggest an out-of-tree build directory) - 4- Click the Configure button - 7- Click the Generate button - 8- The Visual Studio solution should now be in the folder you previously specified For Linux users: -------------- **TODO** Controls: -------------- Player 1: - Left -> Left Arrow - Right -> Right Arrow - Up -> Up Arrow - Down -> Down Arrow - A -> O - B -> P - Select -> Right Shift - Start -> Enter Player 2: - Left -> A - Right -> D - Up -> W - Down -> S - A -> V - B -> B - Select -> Left Shift - Start -> Space
bsd-3-clause
ric2b/Vivaldi-browser
chromium/components/page_load_metrics/browser/metrics_web_contents_observer_unittest.cc
69984
// Copyright 2015 The Chromium 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 "components/page_load_metrics/browser/metrics_web_contents_observer.h" #include <memory> #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/process/kill.h" #include "base/test/metrics/histogram_tester.h" #include "base/test/scoped_feature_list.h" #include "base/time/time.h" #include "base/timer/mock_timer.h" #include "components/page_load_metrics/browser/page_load_metrics_test_content_browser_client.h" #include "components/page_load_metrics/browser/page_load_tracker.h" #include "components/page_load_metrics/browser/test_metrics_web_contents_observer_embedder.h" #include "content/public/browser/back_forward_cache.h" #include "content/public/browser/navigation_handle.h" #include "content/public/common/content_client.h" #include "content/public/common/content_features.h" #include "content/public/test/navigation_simulator.h" #include "content/public/test/render_frame_host_test_support.h" #include "content/public/test/test_renderer_host.h" #include "net/base/net_errors.h" #include "net/cert/cert_status_flags.h" #include "services/network/public/mojom/fetch_api.mojom.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/blink/public/common/use_counter/use_counter_feature.h" #include "third_party/blink/public/mojom/loader/resource_load_info.mojom.h" #include "third_party/blink/public/mojom/use_counter/use_counter_feature.mojom-shared.h" #include "url/url_constants.h" using content::NavigationSimulator; namespace page_load_metrics { namespace { const char kDefaultTestUrl[] = "https://google.com/"; const char kDefaultTestUrlAnchor[] = "https://google.com/#samedocument"; const char kDefaultTestUrl2[] = "https://whatever.com/"; const char kFilteredStartUrl[] = "https://whatever.com/ignore-on-start"; const char kFilteredCommitUrl[] = "https://whatever.com/ignore-on-commit"; void PopulatePageLoadTiming(mojom::PageLoadTiming* timing) { page_load_metrics::InitPageLoadTimingForTest(timing); timing->navigation_start = base::Time::FromDoubleT(1); timing->response_start = base::Milliseconds(10); timing->parse_timing->parse_start = base::Milliseconds(20); } blink::mojom::ResourceLoadInfoPtr CreateResourceLoadInfo( const GURL& url, network::mojom::RequestDestination request_destination) { blink::mojom::ResourceLoadInfoPtr resource_load_info = blink::mojom::ResourceLoadInfo::New(); resource_load_info->final_url = url; resource_load_info->original_url = url; resource_load_info->request_destination = request_destination; resource_load_info->was_cached = false; resource_load_info->raw_body_bytes = 0; resource_load_info->net_error = net::OK; resource_load_info->network_info = blink::mojom::CommonNetworkInfo::New(); resource_load_info->network_info->remote_endpoint = net::IPEndPoint(); resource_load_info->load_timing_info.request_start = base::TimeTicks::Now(); return resource_load_info; } } // namespace class MetricsWebContentsObserverTest : public content::RenderViewHostTestHarness { public: MetricsWebContentsObserverTest() { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); previous_timing_ = timing.Clone(); } MetricsWebContentsObserverTest(const MetricsWebContentsObserverTest&) = delete; MetricsWebContentsObserverTest& operator=( const MetricsWebContentsObserverTest&) = delete; void SetUp() override { content::RenderViewHostTestHarness::SetUp(); original_browser_client_ = content::SetBrowserClientForTesting(&browser_client_); AttachObserver(); } void TearDown() override { content::SetBrowserClientForTesting(original_browser_client_); RenderViewHostTestHarness::TearDown(); } void NavigateToUntrackedUrl() { content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(url::kAboutBlankURL)); } // Returns the mock timer used for buffering updates in the // PageLoadMetricsUpdateDispatcher. base::MockOneShotTimer* GetMostRecentTimer() { return embedder_interface_->GetMockTimer(); } void SimulateTimingUpdate(const mojom::PageLoadTiming& timing) { SimulateTimingUpdate(timing, web_contents()->GetMainFrame()); } void SimulateCpuTimingUpdate(const mojom::CpuTiming& timing, content::RenderFrameHost* render_frame_host) { observer()->OnTimingUpdated( render_frame_host, previous_timing_->Clone(), mojom::FrameMetadataPtr(base::in_place), std::vector<blink::UseCounterFeature>(), std::vector<mojom::ResourceDataUpdatePtr>(), mojom::FrameRenderDataUpdatePtr(base::in_place), timing.Clone(), mojom::DeferredResourceCountsPtr(base::in_place), mojom::InputTimingPtr(base::in_place), blink::MobileFriendliness()); } void SimulateTimingUpdate(const mojom::PageLoadTiming& timing, content::RenderFrameHost* render_frame_host) { SimulateTimingUpdateWithoutFiringDispatchTimer(timing, render_frame_host); // If sending the timing update caused the PageLoadMetricsUpdateDispatcher // to schedule a buffering timer, then fire it now so metrics are dispatched // to observers. base::MockOneShotTimer* mock_timer = GetMostRecentTimer(); if (mock_timer && mock_timer->IsRunning()) mock_timer->Fire(); } void SimulateTimingUpdateWithoutFiringDispatchTimer( const mojom::PageLoadTiming& timing, content::RenderFrameHost* render_frame_host) { previous_timing_ = timing.Clone(); observer()->OnTimingUpdated( render_frame_host, timing.Clone(), mojom::FrameMetadataPtr(base::in_place), std::vector<blink::UseCounterFeature>(), std::vector<mojom::ResourceDataUpdatePtr>(), mojom::FrameRenderDataUpdatePtr(base::in_place), mojom::CpuTimingPtr(base::in_place), mojom::DeferredResourceCountsPtr(base::in_place), mojom::InputTimingPtr(base::in_place), blink::MobileFriendliness()); } virtual std::unique_ptr<TestMetricsWebContentsObserverEmbedder> CreateEmbedder() { return std::make_unique<TestMetricsWebContentsObserverEmbedder>(); } void AttachObserver() { auto embedder_interface = CreateEmbedder(); embedder_interface_ = embedder_interface.get(); MetricsWebContentsObserver* observer = MetricsWebContentsObserver::CreateForWebContents( web_contents(), std::move(embedder_interface)); observer->OnVisibilityChanged(content::Visibility::VISIBLE); } void CheckErrorEvent(InternalErrorLoadEvent error, int count) { histogram_tester_.ExpectBucketCount(internal::kErrorEvents, error, count); num_errors_ += count; } void CheckTotalErrorEvents() { histogram_tester_.ExpectTotalCount(internal::kErrorEvents, num_errors_); } void CheckNoErrorEvents() { histogram_tester_.ExpectTotalCount(internal::kErrorEvents, 0); } int CountEmptyCompleteTimingReported() { int empty = 0; for (const auto& timing : embedder_interface_->complete_timings()) { if (page_load_metrics::IsEmpty(*timing)) ++empty; } return empty; } void CheckErrorNoIPCsReceivedIfNeeded(int count) { // With BackForwardCache, page is kept alive after navigation. // ERR_NO_IPCS_RECEIVED isn't recorded as it is reported during destruction // of page after navigation which doesn't happen with BackForwardCache. if (!content::BackForwardCache::IsBackForwardCacheFeatureEnabled()) CheckErrorEvent(ERR_NO_IPCS_RECEIVED, count); } const std::vector<mojom::PageLoadTimingPtr>& updated_timings() const { return embedder_interface_->updated_timings(); } const std::vector<mojom::CpuTimingPtr>& updated_cpu_timings() const { return embedder_interface_->updated_cpu_timings(); } const std::vector<mojom::PageLoadTimingPtr>& complete_timings() const { return embedder_interface_->complete_timings(); } const std::vector<mojom::PageLoadTimingPtr>& updated_subframe_timings() const { return embedder_interface_->updated_subframe_timings(); } int CountCompleteTimingReported() { return complete_timings().size(); } int CountUpdatedTimingReported() { return updated_timings().size(); } int CountUpdatedCpuTimingReported() { return updated_cpu_timings().size(); } int CountUpdatedSubFrameTimingReported() { return updated_subframe_timings().size(); } int CountOnBackForwardCacheEntered() const { return embedder_interface_->count_on_enter_back_forward_cache(); } const std::vector<GURL>& observed_committed_urls_from_on_start() const { return embedder_interface_->observed_committed_urls_from_on_start(); } const std::vector<GURL>& observed_aborted_urls() const { return embedder_interface_->observed_aborted_urls(); } const std::vector<blink::UseCounterFeature>& observed_features() const { return embedder_interface_->observed_features(); } const absl::optional<bool>& is_first_navigation_in_web_contents() const { return embedder_interface_->is_first_navigation_in_web_contents(); } const std::vector<GURL>& completed_filtered_urls() const { return embedder_interface_->completed_filtered_urls(); } const std::vector<ExtraRequestCompleteInfo>& loaded_resources() const { return embedder_interface_->loaded_resources(); } protected: MetricsWebContentsObserver* observer() { return MetricsWebContentsObserver::FromWebContents(web_contents()); } base::HistogramTester histogram_tester_; raw_ptr<TestMetricsWebContentsObserverEmbedder> embedder_interface_; private: int num_errors_ = 0; // Since we have two types of updates, both CpuTiming and PageLoadTiming, and // these feed into a singular OnTimingUpdated, we need to pass in an unchanged // PageLoadTiming structure to this function, so we need to keep track of the // previous structure that was passed when updating the PageLoadTiming. mojom::PageLoadTimingPtr previous_timing_; PageLoadMetricsTestContentBrowserClient browser_client_; raw_ptr<content::ContentBrowserClient> original_browser_client_ = nullptr; }; TEST_F(MetricsWebContentsObserverTest, SuccessfulMainFrameNavigation) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(1); ASSERT_TRUE(observed_committed_urls_from_on_start().empty()); ASSERT_FALSE(is_first_navigation_in_web_contents().has_value()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(1u, observed_committed_urls_from_on_start().size()); ASSERT_TRUE(observed_committed_urls_from_on_start().at(0).is_empty()); ASSERT_TRUE(is_first_navigation_in_web_contents().has_value()); ASSERT_TRUE(is_first_navigation_in_web_contents().value()); ASSERT_EQ(0, CountUpdatedTimingReported()); SimulateTimingUpdate(timing); ASSERT_EQ(1, CountUpdatedTimingReported()); ASSERT_EQ(0, CountCompleteTimingReported()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_FALSE(is_first_navigation_in_web_contents().value()); ASSERT_EQ(1, CountCompleteTimingReported()); ASSERT_EQ(0, CountEmptyCompleteTimingReported()); ASSERT_EQ(2u, observed_committed_urls_from_on_start().size()); ASSERT_EQ(kDefaultTestUrl, observed_committed_urls_from_on_start().at(1).spec()); ASSERT_EQ(1, CountUpdatedTimingReported()); ASSERT_EQ(0, CountUpdatedSubFrameTimingReported()); CheckNoErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, DISABLED_MainFrameNavigationInternalAbort) { auto navigation = content::NavigationSimulator::CreateBrowserInitiated( GURL(kDefaultTestUrl), web_contents()); navigation->Fail(net::ERR_ABORTED); ASSERT_EQ(1u, observed_aborted_urls().size()); ASSERT_EQ(kDefaultTestUrl, observed_aborted_urls().front().spec()); } TEST_F(MetricsWebContentsObserverTest, SubFrame) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(1); timing.response_start = base::Milliseconds(10); timing.parse_timing->parse_start = base::Milliseconds(20); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); ASSERT_EQ(1, CountUpdatedTimingReported()); EXPECT_TRUE(timing.Equals(*updated_timings().back())); content::RenderFrameHostTester* rfh_tester = content::RenderFrameHostTester::For(main_rfh()); content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); // Dispatch a timing update for the child frame that includes a first paint. mojom::PageLoadTiming subframe_timing; page_load_metrics::InitPageLoadTimingForTest(&subframe_timing); subframe_timing.navigation_start = base::Time::FromDoubleT(2); subframe_timing.response_start = base::Milliseconds(10); subframe_timing.parse_timing->parse_start = base::Milliseconds(20); subframe_timing.paint_timing->first_paint = base::Milliseconds(40); subframe = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe); SimulateTimingUpdate(subframe_timing, subframe); ASSERT_EQ(1, CountUpdatedSubFrameTimingReported()); EXPECT_TRUE(subframe_timing.Equals(*updated_subframe_timings().back())); // The subframe update which included a paint should have also triggered // a main frame update, which includes a first paint. ASSERT_EQ(2, CountUpdatedTimingReported()); EXPECT_FALSE(timing.Equals(*updated_timings().back())); EXPECT_TRUE(updated_timings().back()->paint_timing->first_paint); // Navigate again to see if the timing updated for a subframe message. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(1, CountCompleteTimingReported()); ASSERT_EQ(2, CountUpdatedTimingReported()); ASSERT_EQ(0, CountEmptyCompleteTimingReported()); ASSERT_EQ(1, CountUpdatedSubFrameTimingReported()); EXPECT_TRUE(subframe_timing.Equals(*updated_subframe_timings().back())); CheckNoErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, SameDocumentNoTrigger) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(1); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(0, CountUpdatedTimingReported()); SimulateTimingUpdate(timing); ASSERT_EQ(1, CountUpdatedTimingReported()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrlAnchor)); // Send the same timing update. The original tracker for kDefaultTestUrl // should dedup the update, and the tracker for kDefaultTestUrlAnchor should // have been destroyed as a result of its being a same page navigation, so // CountUpdatedTimingReported() should continue to return 1. SimulateTimingUpdate(timing); ASSERT_EQ(1, CountUpdatedTimingReported()); ASSERT_EQ(0, CountCompleteTimingReported()); // Navigate again to force histogram logging. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); // A same page navigation shouldn't trigger logging UMA for the original. ASSERT_EQ(1, CountUpdatedTimingReported()); ASSERT_EQ(1, CountCompleteTimingReported()); ASSERT_EQ(0, CountEmptyCompleteTimingReported()); CheckNoErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, DontLogNewTabPage) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(1); embedder_interface_->set_is_ntp(true); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(0, CountUpdatedTimingReported()); ASSERT_EQ(0, CountCompleteTimingReported()); // Ensure that NTP and other untracked loads are still accounted for as part // of keeping track of the first navigation in the WebContents. embedder_interface_->set_is_ntp(false); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_TRUE(is_first_navigation_in_web_contents().has_value()); ASSERT_FALSE(is_first_navigation_in_web_contents().value()); CheckErrorEvent(ERR_IPC_WITH_NO_RELEVANT_LOAD, 1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, DontLogIrrelevantNavigation) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(10); GURL about_blank_url = GURL("about:blank"); content::NavigationSimulator::NavigateAndCommitFromBrowser(web_contents(), about_blank_url); SimulateTimingUpdate(timing); ASSERT_EQ(0, CountUpdatedTimingReported()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(0, CountUpdatedTimingReported()); ASSERT_EQ(0, CountCompleteTimingReported()); // Ensure that NTP and other untracked loads are still accounted for as part // of keeping track of the first navigation in the WebContents. ASSERT_TRUE(is_first_navigation_in_web_contents().has_value()); ASSERT_FALSE(is_first_navigation_in_web_contents().value()); CheckErrorEvent(ERR_IPC_FROM_BAD_URL_SCHEME, 0); CheckErrorEvent(ERR_IPC_WITH_NO_RELEVANT_LOAD, 1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, EmptyTimingError) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); ASSERT_EQ(0, CountUpdatedTimingReported()); NavigateToUntrackedUrl(); ASSERT_EQ(0, CountUpdatedTimingReported()); ASSERT_EQ(1, CountCompleteTimingReported()); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorEvent(ERR_NO_IPCS_RECEIVED, 1); CheckTotalErrorEvents(); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal::INVALID_EMPTY_TIMING, 1); } TEST_F(MetricsWebContentsObserverTest, NullNavigationStartError) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.parse_timing->parse_start = base::Milliseconds(1); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); ASSERT_EQ(0, CountUpdatedTimingReported()); NavigateToUntrackedUrl(); ASSERT_EQ(0, CountUpdatedTimingReported()); ASSERT_EQ(1, CountCompleteTimingReported()); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorEvent(ERR_NO_IPCS_RECEIVED, 1); CheckTotalErrorEvents(); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal::INVALID_NULL_NAVIGATION_START, 1); } TEST_F(MetricsWebContentsObserverTest, TimingOrderError) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(1); timing.parse_timing->parse_stop = base::Milliseconds(1); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); ASSERT_EQ(0, CountUpdatedTimingReported()); NavigateToUntrackedUrl(); ASSERT_EQ(0, CountUpdatedTimingReported()); ASSERT_EQ(1, CountCompleteTimingReported()); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorEvent(ERR_NO_IPCS_RECEIVED, 1); CheckTotalErrorEvents(); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal::INVALID_ORDER_PARSE_START_PARSE_STOP, 1); } TEST_F(MetricsWebContentsObserverTest, BadIPC) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(10); mojom::PageLoadTiming timing2; page_load_metrics::InitPageLoadTimingForTest(&timing2); timing2.navigation_start = base::Time::FromDoubleT(100); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); ASSERT_EQ(1, CountUpdatedTimingReported()); SimulateTimingUpdate(timing2); ASSERT_EQ(1, CountUpdatedTimingReported()); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING_DESCENDENT, 1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, ObservePartialNavigation) { // Reset the state of the tests, and attach the MetricsWebContentsObserver in // the middle of a navigation. This tests that the class is robust to only // observing some of a navigation. DeleteContents(); SetContents(CreateTestWebContents()); mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(10); // Start the navigation, then start observing the web contents. This used to // crash us. Make sure we bail out and don't log histograms. std::unique_ptr<NavigationSimulator> navigation = NavigationSimulator::CreateBrowserInitiated(GURL(kDefaultTestUrl), web_contents()); navigation->Start(); AttachObserver(); navigation->Commit(); SimulateTimingUpdate(timing); // Navigate again to force histogram logging. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(0, CountCompleteTimingReported()); ASSERT_EQ(0, CountUpdatedTimingReported()); CheckErrorEvent(ERR_IPC_WITH_NO_RELEVANT_LOAD, 1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, DontLogAbortChains) { NavigateAndCommit(GURL(kDefaultTestUrl)); NavigateAndCommit(GURL(kDefaultTestUrl2)); NavigateAndCommit(GURL(kDefaultTestUrl)); histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNewNavigation, 0); CheckErrorNoIPCsReceivedIfNeeded(2); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, LogAbortChains) { // Start and abort three loads before one finally commits. NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl), net::ERR_ABORTED); NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl2), net::ERR_ABORTED); NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl), net::ERR_ABORTED); NavigationSimulator::NavigateAndCommitFromBrowser(web_contents(), GURL(kDefaultTestUrl2)); histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNewNavigation, 1); histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNewNavigation, 3, 1); CheckNoErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, LogAbortChainsSameURL) { // Start and abort three loads before one finally commits. NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl), net::ERR_ABORTED); NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl), net::ERR_ABORTED); NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl), net::ERR_ABORTED); NavigationSimulator::NavigateAndCommitFromBrowser(web_contents(), GURL(kDefaultTestUrl)); histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNewNavigation, 1); histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNewNavigation, 3, 1); histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeSameURL, 1); histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeSameURL, 3, 1); } TEST_F(MetricsWebContentsObserverTest, LogAbortChainsNoCommit) { // Start and abort three loads before one finally commits. NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl), net::ERR_ABORTED); NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl2), net::ERR_ABORTED); NavigationSimulator::NavigateAndFailFromBrowser( web_contents(), GURL(kDefaultTestUrl), net::ERR_ABORTED); web_contents()->Stop(); histogram_tester_.ExpectTotalCount(internal::kAbortChainSizeNoCommit, 1); histogram_tester_.ExpectBucketCount(internal::kAbortChainSizeNoCommit, 3, 1); } TEST_F(MetricsWebContentsObserverTest, FlushMetricsOnAppEnterBackground) { content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); histogram_tester_.ExpectTotalCount( internal::kPageLoadCompletedAfterAppBackground, 0); observer()->FlushMetricsOnAppEnterBackground(); histogram_tester_.ExpectTotalCount( internal::kPageLoadCompletedAfterAppBackground, 1); histogram_tester_.ExpectBucketCount( internal::kPageLoadCompletedAfterAppBackground, false, 1); histogram_tester_.ExpectBucketCount( internal::kPageLoadCompletedAfterAppBackground, true, 0); // Navigate again, which forces completion callbacks on the previous // navigation to be invoked. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); // Verify that, even though the page load completed, no complete timings were // reported, because the TestPageLoadMetricsObserver's // FlushMetricsOnAppEnterBackground implementation returned STOP_OBSERVING, // thus preventing OnComplete from being invoked. ASSERT_EQ(0, CountCompleteTimingReported()); DeleteContents(); histogram_tester_.ExpectTotalCount( internal::kPageLoadCompletedAfterAppBackground, 2); histogram_tester_.ExpectBucketCount( internal::kPageLoadCompletedAfterAppBackground, false, 1); histogram_tester_.ExpectBucketCount( internal::kPageLoadCompletedAfterAppBackground, true, 1); } TEST_F(MetricsWebContentsObserverTest, StopObservingOnCommit) { ASSERT_TRUE(completed_filtered_urls().empty()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_TRUE(completed_filtered_urls().empty()); // kFilteredCommitUrl should stop observing in OnCommit, and thus should not // reach OnComplete(). content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kFilteredCommitUrl)); ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}), completed_filtered_urls()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}), completed_filtered_urls()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl), GURL(kDefaultTestUrl2)}), completed_filtered_urls()); } TEST_F(MetricsWebContentsObserverTest, StopObservingOnStart) { ASSERT_TRUE(completed_filtered_urls().empty()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_TRUE(completed_filtered_urls().empty()); // kFilteredCommitUrl should stop observing in OnStart, and thus should not // reach OnComplete(). content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kFilteredStartUrl)); ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}), completed_filtered_urls()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl)}), completed_filtered_urls()); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(std::vector<GURL>({GURL(kDefaultTestUrl), GURL(kDefaultTestUrl2)}), completed_filtered_urls()); } // We buffer cross frame timings in order to provide a consistent view of // timing data to observers. See crbug.com/722860 for more. TEST_F(MetricsWebContentsObserverTest, OutOfOrderCrossFrameTiming) { mojom::PageLoadTiming timing; page_load_metrics::InitPageLoadTimingForTest(&timing); timing.navigation_start = base::Time::FromDoubleT(1); timing.response_start = base::Milliseconds(10); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); ASSERT_EQ(1, CountUpdatedTimingReported()); EXPECT_TRUE(timing.Equals(*updated_timings().back())); content::RenderFrameHostTester* rfh_tester = content::RenderFrameHostTester::For(main_rfh()); content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); // Dispatch a timing update for the child frame that includes a first paint. mojom::PageLoadTiming subframe_timing; PopulatePageLoadTiming(&subframe_timing); subframe_timing.paint_timing->first_paint = base::Milliseconds(40); subframe = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe); SimulateTimingUpdate(subframe_timing, subframe); // Though a first paint was dispatched in the child, it should not yet be // reflected as an updated timing in the main frame, since the main frame // hasn't received updates for required earlier events such as parse_start. ASSERT_EQ(1, CountUpdatedSubFrameTimingReported()); EXPECT_TRUE(subframe_timing.Equals(*updated_subframe_timings().back())); ASSERT_EQ(1, CountUpdatedTimingReported()); EXPECT_TRUE(timing.Equals(*updated_timings().back())); // Dispatch the parse_start event in the parent. We should now unbuffer the // first paint main frame update and receive a main frame update with a first // paint value. timing.parse_timing->parse_start = base::Milliseconds(20); SimulateTimingUpdate(timing); ASSERT_EQ(2, CountUpdatedTimingReported()); EXPECT_FALSE(timing.Equals(*updated_timings().back())); EXPECT_TRUE( updated_timings().back()->parse_timing->Equals(*timing.parse_timing)); EXPECT_TRUE(updated_timings().back()->document_timing->Equals( *timing.document_timing)); EXPECT_FALSE( updated_timings().back()->paint_timing->Equals(*timing.paint_timing)); EXPECT_TRUE(updated_timings().back()->paint_timing->first_paint); // Navigate again to see if the timing updated for a subframe message. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(1, CountCompleteTimingReported()); ASSERT_EQ(2, CountUpdatedTimingReported()); ASSERT_EQ(0, CountEmptyCompleteTimingReported()); ASSERT_EQ(1, CountUpdatedSubFrameTimingReported()); EXPECT_TRUE(subframe_timing.Equals(*updated_subframe_timings().back())); CheckNoErrorEvents(); } // We buffer cross-frame paint updates to account for paint timings from // different frames arriving out of order. TEST_F(MetricsWebContentsObserverTest, OutOfOrderCrossFrameTiming2) { // Dispatch a timing update for the main frame that includes a first // paint. This should be buffered, with the dispatch timer running. mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); // Ensure this is much bigger than the subframe first paint below. We // currently can't inject the navigation start offset, so we must ensure that // subframe first paint + navigation start offset < main frame first paint. timing.paint_timing->first_paint = base::Milliseconds(100000); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdateWithoutFiringDispatchTimer(timing, main_rfh()); EXPECT_TRUE(GetMostRecentTimer()->IsRunning()); ASSERT_EQ(0, CountUpdatedTimingReported()); content::RenderFrameHostTester* rfh_tester = content::RenderFrameHostTester::For(main_rfh()); // Dispatch a timing update for a child frame that includes a first paint. mojom::PageLoadTiming subframe_timing; PopulatePageLoadTiming(&subframe_timing); subframe_timing.paint_timing->first_paint = base::Milliseconds(500); content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); subframe = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe); SimulateTimingUpdateWithoutFiringDispatchTimer(subframe_timing, subframe); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kHistogramOutOfOrderTiming, 1); EXPECT_TRUE(GetMostRecentTimer()->IsRunning()); ASSERT_EQ(0, CountUpdatedTimingReported()); // At this point, the timing update is buffered, waiting for the timer to // fire. GetMostRecentTimer()->Fire(); // Firing the timer should produce a timing update. The update should be a // merged view of the main frame timing, with a first paint timestamp from the // subframe. ASSERT_EQ(1, CountUpdatedTimingReported()); EXPECT_FALSE(timing.Equals(*updated_timings().back())); EXPECT_TRUE( updated_timings().back()->parse_timing->Equals(*timing.parse_timing)); EXPECT_TRUE(updated_timings().back()->document_timing->Equals( *timing.document_timing)); EXPECT_FALSE( updated_timings().back()->paint_timing->Equals(*timing.paint_timing)); EXPECT_TRUE(updated_timings().back()->paint_timing->first_paint); // The first paint value should be the min of all received first paints, which // in this case is the first paint from the subframe. Since it is offset by // the subframe's navigation start, the received value should be >= the first // paint value specified in the subframe. EXPECT_GE(updated_timings().back()->paint_timing->first_paint, subframe_timing.paint_timing->first_paint); EXPECT_LT(updated_timings().back()->paint_timing->first_paint, timing.paint_timing->first_paint); base::TimeDelta initial_first_paint = updated_timings().back()->paint_timing->first_paint.value(); // Dispatch a timing update for an additional child frame, with an earlier // first paint time. This should cause an immediate update, without a timer // delay. subframe_timing.paint_timing->first_paint = base::Milliseconds(50); content::RenderFrameHost* subframe2 = rfh_tester->AppendChild("subframe"); subframe2 = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe2); SimulateTimingUpdateWithoutFiringDispatchTimer(subframe_timing, subframe2); base::TimeDelta updated_first_paint = updated_timings().back()->paint_timing->first_paint.value(); EXPECT_FALSE(GetMostRecentTimer()->IsRunning()); ASSERT_EQ(2, CountUpdatedTimingReported()); EXPECT_LT(updated_first_paint, initial_first_paint); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kHistogramOutOfOrderTimingBuffered, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kHistogramOutOfOrderTimingBuffered, (initial_first_paint - updated_first_paint).InMilliseconds(), 1); CheckNoErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, FlushBufferOnAppBackground) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.paint_timing->first_paint = base::Milliseconds(100000); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdateWithoutFiringDispatchTimer(timing, main_rfh()); ASSERT_EQ(0, CountUpdatedTimingReported()); observer()->FlushMetricsOnAppEnterBackground(); ASSERT_EQ(1, CountUpdatedTimingReported()); } TEST_F(MetricsWebContentsObserverTest, FirstInputDelayMissingFirstInputTimestamp) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.interactive_timing->first_input_delay = base::Milliseconds(10); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; // Won't have been set, as we're missing the first_input_timestamp. EXPECT_FALSE(interactive_timing.first_input_delay.has_value()); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal::INVALID_NULL_FIRST_INPUT_TIMESTAMP, 1); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorNoIPCsReceivedIfNeeded(1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, FirstInputTimestampMissingFirstInputDelay) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.interactive_timing->first_input_timestamp = base::Milliseconds(10); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; // Won't have been set, as we're missing the first_input_delay. EXPECT_FALSE(interactive_timing.first_input_timestamp.has_value()); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal::INVALID_NULL_FIRST_INPUT_DELAY, 1); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorNoIPCsReceivedIfNeeded(1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, LongestInputDelayMissingLongestInputTimestamp) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.interactive_timing->longest_input_delay = base::Milliseconds(10); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; // Won't have been set, as we're missing the longest_input_timestamp. EXPECT_FALSE(interactive_timing.longest_input_delay.has_value()); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal::INVALID_NULL_LONGEST_INPUT_TIMESTAMP, 1); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorNoIPCsReceivedIfNeeded(1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, LongestInputTimestampMissingLongestInputDelay) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.interactive_timing->longest_input_timestamp = base::Milliseconds(10); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; // Won't have been set, as we're missing the longest_input_delay. EXPECT_FALSE(interactive_timing.longest_input_timestamp.has_value()); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal::INVALID_NULL_LONGEST_INPUT_DELAY, 1); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorNoIPCsReceivedIfNeeded(1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, LongestInputDelaySmallerThanFirstInputDelay) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.interactive_timing->first_input_delay = base::Milliseconds(50); timing.interactive_timing->first_input_timestamp = base::Milliseconds(1000); timing.interactive_timing->longest_input_delay = base::Milliseconds(10); timing.interactive_timing->longest_input_timestamp = base::Milliseconds(2000); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; // Won't have been set, as it's invalid. EXPECT_FALSE(interactive_timing.longest_input_delay.has_value()); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal:: INVALID_LONGEST_INPUT_DELAY_LESS_THAN_FIRST_INPUT_DELAY, 1); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorNoIPCsReceivedIfNeeded(1); CheckTotalErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, LongestInputTimestampEarlierThanFirstInputTimestamp) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.interactive_timing->first_input_delay = base::Milliseconds(50); timing.interactive_timing->first_input_timestamp = base::Milliseconds(1000); timing.interactive_timing->longest_input_delay = base::Milliseconds(60); timing.interactive_timing->longest_input_timestamp = base::Milliseconds(500); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; // Won't have been set, as it's invalid. EXPECT_FALSE(interactive_timing.longest_input_delay.has_value()); histogram_tester_.ExpectTotalCount( page_load_metrics::internal::kPageLoadTimingStatus, 1); histogram_tester_.ExpectBucketCount( page_load_metrics::internal::kPageLoadTimingStatus, page_load_metrics::internal:: INVALID_LONGEST_INPUT_TIMESTAMP_LESS_THAN_FIRST_INPUT_TIMESTAMP, 1); CheckErrorEvent(ERR_BAD_TIMING_IPC_INVALID_TIMING, 1); CheckErrorNoIPCsReceivedIfNeeded(1); CheckTotalErrorEvents(); } // Main frame delivers an input notification. Subsequently, a subframe delivers // an input notification, where the input occurred first. Verify that // FirstInputDelay and FirstInputTimestamp come from the subframe. TEST_F(MetricsWebContentsObserverTest, FirstInputDelayAndTimingSubframeFirstDeliveredSecond) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.interactive_timing->first_input_delay = base::Milliseconds(10); // Set this far in the future. We currently can't control the navigation start // offset, so we ensure that the subframe timestamp + the unknown offset is // less than the main frame timestamp. timing.interactive_timing->first_input_timestamp = base::Minutes(100); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); content::RenderFrameHostTester* rfh_tester = content::RenderFrameHostTester::For(main_rfh()); content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); // Dispatch a timing update for the child frame that includes a first input // earlier than the one for the main frame. mojom::PageLoadTiming subframe_timing; PopulatePageLoadTiming(&subframe_timing); subframe_timing.interactive_timing->first_input_delay = base::Milliseconds(15); subframe_timing.interactive_timing->first_input_timestamp = base::Milliseconds(90); subframe = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe); SimulateTimingUpdate(subframe_timing, subframe); // Navigate again to confirm the timing updated for a subframe message. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; EXPECT_EQ(base::Milliseconds(15), interactive_timing.first_input_delay); // Ensure the timestamp is from the subframe. The main frame timestamp was 100 // minutes. EXPECT_LT(interactive_timing.first_input_timestamp, base::Minutes(10)); CheckNoErrorEvents(); } // A subframe delivers an input notification. Subsequently, the mainframe // delivers an input notification, where the input occurred first. Verify that // FirstInputDelay and FirstInputTimestamp come from the main frame. TEST_F(MetricsWebContentsObserverTest, FirstInputDelayAndTimingMainframeFirstDeliveredSecond) { // We need to navigate before we can navigate the subframe. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); content::RenderFrameHostTester* rfh_tester = content::RenderFrameHostTester::For(main_rfh()); content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); mojom::PageLoadTiming subframe_timing; PopulatePageLoadTiming(&subframe_timing); subframe_timing.interactive_timing->first_input_delay = base::Milliseconds(10); subframe_timing.interactive_timing->first_input_timestamp = base::Minutes(100); subframe = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe); SimulateTimingUpdate(subframe_timing, subframe); mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); // Dispatch a timing update for the main frame that includes a first input // earlier than the one for the subframe. timing.interactive_timing->first_input_delay = base::Milliseconds(15); // Set this far in the future. We currently can't control the navigation start // offset, so we ensure that the main frame timestamp + the unknown offset is // less than the subframe timestamp. timing.interactive_timing->first_input_timestamp = base::Milliseconds(90); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(timing); // Navigate again to confirm the timing updated for the mainframe message. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; EXPECT_EQ(base::Milliseconds(15), interactive_timing.first_input_delay); // Ensure the timestamp is from the main frame. The subframe timestamp was 100 // minutes. EXPECT_LT(interactive_timing.first_input_timestamp, base::Minutes(10)); CheckNoErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, DISABLED_LongestInputInMainFrame) { // We need to navigate before we can navigate the subframe. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); content::RenderFrameHostTester* rfh_tester = content::RenderFrameHostTester::For(main_rfh()); content::RenderFrameHost* subframe = rfh_tester->AppendChild("subframe"); mojom::PageLoadTiming subframe_timing; PopulatePageLoadTiming(&subframe_timing); subframe_timing.interactive_timing->longest_input_delay = base::Milliseconds(70); subframe_timing.interactive_timing->longest_input_timestamp = base::Milliseconds(1000); subframe = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe); SimulateTimingUpdate(subframe_timing, subframe); mojom::PageLoadTiming main_frame_timing; PopulatePageLoadTiming(&main_frame_timing); // Dispatch a timing update for the main frame that includes a longest input // delay longer than the one for the subframe. main_frame_timing.interactive_timing->longest_input_delay = base::Milliseconds(100); main_frame_timing.interactive_timing->longest_input_timestamp = base::Milliseconds(2000); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(main_frame_timing); // Second subframe. content::RenderFrameHost* subframe2 = rfh_tester->AppendChild("subframe2"); mojom::PageLoadTiming subframe2_timing; PopulatePageLoadTiming(&subframe2_timing); subframe2_timing.interactive_timing->longest_input_delay = base::Milliseconds(80); subframe2_timing.interactive_timing->longest_input_timestamp = base::Milliseconds(3000); subframe2 = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe2); SimulateTimingUpdate(subframe2_timing, subframe2); // Navigate again to confirm all timings are updated. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; EXPECT_EQ(base::Milliseconds(100), interactive_timing.longest_input_delay); EXPECT_EQ(base::Milliseconds(2000), interactive_timing.longest_input_timestamp); CheckNoErrorEvents(); } // ----------------------------------------------------------------------------- // | | | // 1s 2s 3s // Subframe1 Main Frame Subframe2 // LID (15ms) LID (100ms) LID (200ms) // // Delivery order: Main Frame -> Subframe1 -> Subframe2. TEST_F(MetricsWebContentsObserverTest, LongestInputInSubframe) { mojom::PageLoadTiming main_frame_timing; PopulatePageLoadTiming(&main_frame_timing); main_frame_timing.interactive_timing->longest_input_delay = base::Milliseconds(100); main_frame_timing.interactive_timing->longest_input_timestamp = base::Milliseconds(2000); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdate(main_frame_timing); content::RenderFrameHostTester* rfh_tester = content::RenderFrameHostTester::For(main_rfh()); // First subframe. content::RenderFrameHost* subframe1 = rfh_tester->AppendChild("subframe1"); mojom::PageLoadTiming subframe_timing; PopulatePageLoadTiming(&subframe_timing); subframe_timing.interactive_timing->longest_input_delay = base::Milliseconds(15); subframe_timing.interactive_timing->longest_input_timestamp = base::Milliseconds(1000); subframe1 = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe1); SimulateTimingUpdate(subframe_timing, subframe1); // Second subframe. content::RenderFrameHost* subframe2 = rfh_tester->AppendChild("subframe2"); mojom::PageLoadTiming subframe2_timing; PopulatePageLoadTiming(&subframe2_timing); subframe2_timing.interactive_timing->longest_input_delay = base::Milliseconds(200); subframe2_timing.interactive_timing->longest_input_timestamp = base::Milliseconds(3000); // TODO: Make this url3. subframe2 = content::NavigationSimulator::NavigateAndCommitFromDocument( GURL(kDefaultTestUrl2), subframe2); SimulateTimingUpdate(subframe2_timing, subframe2); // Navigate again to confirm all timings are updated. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); const mojom::InteractiveTiming& interactive_timing = *complete_timings().back()->interactive_timing; EXPECT_EQ(base::Milliseconds(200), interactive_timing.longest_input_delay); // Actual LID timestamp includes the delta between navigation start in // subframe2 and navigation time in the main frame. That delta varies with // different runs, so we only check here that the timestamp is greater than // 3s. EXPECT_GT(interactive_timing.longest_input_timestamp.value(), base::Milliseconds(3000)); CheckNoErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, DispatchDelayedMetricsOnPageClose) { mojom::PageLoadTiming timing; PopulatePageLoadTiming(&timing); timing.paint_timing->first_paint = base::Milliseconds(1000); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); SimulateTimingUpdateWithoutFiringDispatchTimer(timing, main_rfh()); // Throw in a cpu timing update, shouldn't affect the page timing results. mojom::CpuTiming cpu_timing; cpu_timing.task_time = base::Milliseconds(1000); SimulateCpuTimingUpdate(cpu_timing, main_rfh()); EXPECT_TRUE(GetMostRecentTimer()->IsRunning()); ASSERT_EQ(0, CountUpdatedTimingReported()); ASSERT_EQ(0, CountCompleteTimingReported()); // Navigate to a new page. This should force dispatch of the buffered timing // update. NavigateToUntrackedUrl(); ASSERT_EQ(1, CountUpdatedTimingReported()); ASSERT_EQ(1, CountUpdatedCpuTimingReported()); ASSERT_EQ(1, CountCompleteTimingReported()); EXPECT_TRUE(timing.Equals(*updated_timings().back())); EXPECT_TRUE(timing.Equals(*complete_timings().back())); EXPECT_TRUE(cpu_timing.Equals(*updated_cpu_timings().back())); CheckNoErrorEvents(); } // Make sure the dispatch of CPU occurs immediately. TEST_F(MetricsWebContentsObserverTest, DispatchCpuMetricsImmediately) { content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); mojom::CpuTiming timing; timing.task_time = base::Milliseconds(1000); SimulateCpuTimingUpdate(timing, main_rfh()); ASSERT_EQ(1, CountUpdatedCpuTimingReported()); EXPECT_TRUE(timing.Equals(*updated_cpu_timings().back())); // Navigate to a new page. This should force dispatch of the buffered timing // update. NavigateToUntrackedUrl(); ASSERT_EQ(1, CountUpdatedCpuTimingReported()); EXPECT_TRUE(timing.Equals(*updated_cpu_timings().back())); CheckNoErrorEvents(); } TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_MainFrame) { GURL main_resource_url(kDefaultTestUrl); content::NavigationSimulator::NavigateAndCommitFromBrowser(web_contents(), main_resource_url); auto navigation_simulator = content::NavigationSimulator::CreateRendererInitiated( main_resource_url, web_contents()->GetMainFrame()); navigation_simulator->Start(); navigation_simulator->Commit(); const auto request_id = navigation_simulator->GetGlobalRequestID(); observer()->ResourceLoadComplete( web_contents()->GetMainFrame(), request_id, *CreateResourceLoadInfo(main_resource_url, network::mojom::RequestDestination::kFrame)); EXPECT_EQ(1u, loaded_resources().size()); EXPECT_EQ(url::Origin::Create(main_resource_url), loaded_resources().back().origin_of_final_url); NavigateToUntrackedUrl(); // Deliver a second main frame resource. This one should be ignored, since the // specified |request_id| is no longer associated with any tracked page loads. observer()->ResourceLoadComplete( web_contents()->GetMainFrame(), request_id, *CreateResourceLoadInfo(main_resource_url, network::mojom::RequestDestination::kFrame)); EXPECT_EQ(1u, loaded_resources().size()); EXPECT_EQ(url::Origin::Create(main_resource_url), loaded_resources().back().origin_of_final_url); } TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_Subresource) { content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); GURL loaded_resource_url("http://www.other.com/"); observer()->ResourceLoadComplete( web_contents()->GetMainFrame(), content::GlobalRequestID(), *CreateResourceLoadInfo(loaded_resource_url, network::mojom::RequestDestination::kScript)); EXPECT_EQ(1u, loaded_resources().size()); EXPECT_EQ(url::Origin::Create(loaded_resource_url), loaded_resources().back().origin_of_final_url); } TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_ResourceFromOtherRFHIgnored) { content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); content::RenderFrameHost* old_rfh = web_contents()->GetMainFrame(); content::LeaveInPendingDeletionState(old_rfh); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); DCHECK(!old_rfh->IsActive()); observer()->ResourceLoadComplete( old_rfh, content::GlobalRequestID(), *CreateResourceLoadInfo(GURL("http://www.other.com/"), network::mojom::RequestDestination::kScript)); EXPECT_TRUE(loaded_resources().empty()); } TEST_F(MetricsWebContentsObserverTest, OnLoadedResource_IgnoreNonHttpOrHttpsScheme) { content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); GURL loaded_resource_url("data:text/html,Hello world"); observer()->ResourceLoadComplete( web_contents()->GetMainFrame(), content::GlobalRequestID(), *CreateResourceLoadInfo(loaded_resource_url, network::mojom::RequestDestination::kScript)); EXPECT_TRUE(loaded_resources().empty()); } TEST_F(MetricsWebContentsObserverTest, RecordFeatureUsage) { content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(main_rfh()->GetLastCommittedURL().spec(), GURL(kDefaultTestUrl)); MetricsWebContentsObserver::RecordFeatureUsage( main_rfh(), {blink::mojom::WebFeature::kHTMLMarqueeElement, blink::mojom::WebFeature::kFormAttribute}); blink::UseCounterFeature feature1 = { blink::mojom::UseCounterFeatureType::kWebFeature, static_cast<uint32_t>(blink::mojom::WebFeature::kHTMLMarqueeElement), }; blink::UseCounterFeature feature2 = { blink::mojom::UseCounterFeatureType::kWebFeature, static_cast<uint32_t>(blink::mojom::WebFeature::kFormAttribute), }; ASSERT_EQ(observed_features().size(), 2ul); EXPECT_EQ(observed_features()[0], feature1); EXPECT_EQ(observed_features()[1], feature2); } TEST_F(MetricsWebContentsObserverTest, RecordFeatureUsageNoObserver) { // Reset the state of the tests, and don't add an observer. DeleteContents(); SetContents(CreateTestWebContents()); // This call should just do nothing, and should not crash - if that happens, // we are good. MetricsWebContentsObserver::RecordFeatureUsage( main_rfh(), {blink::mojom::WebFeature::kHTMLMarqueeElement, blink::mojom::WebFeature::kFormAttribute}); } class MetricsWebContentsObserverBackForwardCacheTest : public MetricsWebContentsObserverTest, public content::WebContentsDelegate { class CreatedPageLoadTrackerObserver : public MetricsWebContentsObserver::TestingObserver { public: explicit CreatedPageLoadTrackerObserver(content::WebContents* web_contents) : MetricsWebContentsObserver::TestingObserver(web_contents) {} int tracker_committed_count() const { return tracker_committed_count_; } void OnCommit(PageLoadTracker* tracker) override { tracker_committed_count_++; } private: int tracker_committed_count_ = 0; }; public: MetricsWebContentsObserverBackForwardCacheTest() { feature_list_.InitWithFeaturesAndParameters( {{features::kBackForwardCache, {{"TimeToLiveInBackForwardCacheInSeconds", "3600"}}}}, // Allow BackForwardCache for all devices regardless of their memory. {features::kBackForwardCacheMemoryControls}); } ~MetricsWebContentsObserverBackForwardCacheTest() override = default; int tracker_committed_count() const { return created_page_load_tracker_observer_->tracker_committed_count(); } void SetUp() override { MetricsWebContentsObserverTest::SetUp(); created_page_load_tracker_observer_ = std::make_unique<CreatedPageLoadTrackerObserver>(web_contents()); observer()->AddTestingObserver(created_page_load_tracker_observer_.get()); web_contents()->SetDelegate(this); } // content::WebContentsDelegate: bool IsBackForwardCacheSupported() override { return true; } private: base::test::ScopedFeatureList feature_list_; std::unique_ptr<CreatedPageLoadTrackerObserver> created_page_load_tracker_observer_; }; TEST_F(MetricsWebContentsObserverBackForwardCacheTest, RecordFeatureUsageWithBackForwardCache) { content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(main_rfh()->GetLastCommittedURL().spec(), GURL(kDefaultTestUrl)); MetricsWebContentsObserver::RecordFeatureUsage( main_rfh(), blink::mojom::WebFeature::kHTMLMarqueeElement); content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); content::NavigationSimulator::GoBack(web_contents()); MetricsWebContentsObserver::RecordFeatureUsage( main_rfh(), blink::mojom::WebFeature::kFormAttribute); // For now back-forward cached navigations are not tracked and the events // after the history navigation are not tracked. blink::UseCounterFeature feature = { blink::mojom::UseCounterFeatureType::kWebFeature, static_cast<uint32_t>(blink::mojom::WebFeature::kHTMLMarqueeElement), }; EXPECT_THAT(observed_features(), testing::ElementsAre(feature)); } // Checks OnEnterBackForwardCache is called appropriately with back-forward // cache enabled. TEST_F(MetricsWebContentsObserverBackForwardCacheTest, EnterBackForwardCache) { // Go to the URL1. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(main_rfh()->GetLastCommittedURL().spec(), GURL(kDefaultTestUrl)); ASSERT_EQ(0, CountCompleteTimingReported()); EXPECT_EQ(0, CountOnBackForwardCacheEntered()); EXPECT_EQ(1, tracker_committed_count()); // Go to the URL2. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(main_rfh()->GetLastCommittedURL().spec(), GURL(kDefaultTestUrl2)); // With the default implementation of PageLoadMetricsObserver, // OnEnteringBackForwardCache invokes OnComplete and returns STOP_OBSERVING. ASSERT_EQ(1, CountCompleteTimingReported()); EXPECT_EQ(1, CountOnBackForwardCacheEntered()); EXPECT_EQ(2, tracker_committed_count()); // Go back. content::NavigationSimulator::GoBack(web_contents()); EXPECT_EQ(2, CountOnBackForwardCacheEntered()); // Again, OnComplete is assured to be called. ASSERT_EQ(2, CountCompleteTimingReported()); // A new page load tracker is not created or committed. A page load tracker in // the cache is used instead. EXPECT_EQ(2, tracker_committed_count()); } // TODO(hajimehoshi): Detect the document eviction so that PageLoadTracker in // the cache is destroyed. This would call PageLoadMetricsObserver::OnComplete. // This test can be implemented after a PageLoadMetricsObserver's // OnEnterBackForwardCache returns CONTINUE_OBSERVING. class MetricsWebContentsObserverBackForwardCacheDisabledTest : public MetricsWebContentsObserverTest { public: MetricsWebContentsObserverBackForwardCacheDisabledTest() { feature_list_.InitWithFeaturesAndParameters({}, {features::kBackForwardCache}); } ~MetricsWebContentsObserverBackForwardCacheDisabledTest() override = default; private: base::test::ScopedFeatureList feature_list_; }; // Checks OnEnterBackForwardCache is NOT called without back-forward cache // enabled. TEST_F(MetricsWebContentsObserverBackForwardCacheDisabledTest, EnterBackForwardCacheNotCalled) { // Go to the URL1. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(main_rfh()->GetLastCommittedURL().spec(), GURL(kDefaultTestUrl)); ASSERT_EQ(0, CountCompleteTimingReported()); // Go to the URL2. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(main_rfh()->GetLastCommittedURL().spec(), GURL(kDefaultTestUrl2)); ASSERT_EQ(1, CountCompleteTimingReported()); EXPECT_EQ(0, CountOnBackForwardCacheEntered()); // Go back. content::NavigationSimulator::GoBack(web_contents()); EXPECT_EQ(0, CountOnBackForwardCacheEntered()); ASSERT_EQ(2, CountCompleteTimingReported()); } class MetricsWebContentsObserverNonPrimaryPageTest : public MetricsWebContentsObserverBackForwardCacheTest { public: class MetricsObserver : public PageLoadMetricsObserver { public: explicit MetricsObserver( MetricsWebContentsObserverNonPrimaryPageTest* owner) : owner_(owner) {} ObservePolicy OnCommit(content::NavigationHandle* handle, ukm::SourceId source_id) override { committed_url_ = handle->GetURL(); return CONTINUE_OBSERVING; } ObservePolicy OnEnterBackForwardCache( const mojom::PageLoadTiming& timing) override { return CONTINUE_OBSERVING; } void OnV8MemoryChanged( const std::vector<MemoryUpdate>& memory_updates) override { owner_->OnV8MemoryChanged(committed_url_, memory_updates); } private: raw_ptr<MetricsWebContentsObserverNonPrimaryPageTest> owner_; GURL committed_url_; }; class Embedder : public TestMetricsWebContentsObserverEmbedder { public: explicit Embedder(MetricsWebContentsObserverNonPrimaryPageTest* owner) : owner_(owner) {} void RegisterObservers(PageLoadTracker* tracker) override { TestMetricsWebContentsObserverEmbedder::RegisterObservers(tracker); tracker->AddObserver(std::make_unique<MetricsObserver>(owner_)); } private: raw_ptr<MetricsWebContentsObserverNonPrimaryPageTest> owner_; }; std::unique_ptr<TestMetricsWebContentsObserverEmbedder> CreateEmbedder() override { return std::make_unique<Embedder>(this); } void OnV8MemoryChanged(const GURL& url, const std::vector<MemoryUpdate>& memory_updates) { std::vector<MemoryUpdate>& updates_for_url = observed_memory_updates_[url]; updates_for_url.insert(updates_for_url.end(), memory_updates.begin(), memory_updates.end()); } protected: std::map<GURL, std::vector<MemoryUpdate>> observed_memory_updates_; }; TEST_F(MetricsWebContentsObserverNonPrimaryPageTest, MemoryUpdates) { // Go to the URL1. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl)); ASSERT_EQ(main_rfh()->GetLastCommittedURL().spec(), GURL(kDefaultTestUrl)); content::GlobalRenderFrameHostId rfh1_id = main_rfh()->GetGlobalId(); ASSERT_EQ(0, CountCompleteTimingReported()); EXPECT_EQ(0, CountOnBackForwardCacheEntered()); EXPECT_EQ(1, tracker_committed_count()); // Go to the URL2. content::NavigationSimulator::NavigateAndCommitFromBrowser( web_contents(), GURL(kDefaultTestUrl2)); ASSERT_EQ(main_rfh()->GetLastCommittedURL().spec(), GURL(kDefaultTestUrl2)); content::GlobalRenderFrameHostId rfh2_id = main_rfh()->GetGlobalId(); ASSERT_EQ(1, CountCompleteTimingReported()); EXPECT_EQ(1, CountOnBackForwardCacheEntered()); EXPECT_EQ(2, tracker_committed_count()); std::vector<MemoryUpdate> memory_updates = {{rfh1_id, 100}, {rfh2_id, 200}}; observer()->OnV8MemoryChanged(memory_updates); // Verify that memory updates are observed both in primary URL2 and // non-primary URL1. ASSERT_EQ(2u, observed_memory_updates_.size()); ASSERT_EQ(1u, observed_memory_updates_[GURL(kDefaultTestUrl)].size()); EXPECT_EQ(100, observed_memory_updates_[GURL(kDefaultTestUrl)][0].delta_bytes); ASSERT_EQ(1u, observed_memory_updates_[GURL(kDefaultTestUrl2)].size()); EXPECT_EQ(200, observed_memory_updates_[GURL(kDefaultTestUrl2)][0].delta_bytes); } } // namespace page_load_metrics
bsd-3-clause
TeravoxelTwoPhotonTomography/mltk-barry
src/matrix.c
1083
#include "matrix.h" #include <string.h> static float* i33(float * restrict inverse,const float * const restrict t) { #define det(a,b,c,d) (t[a]*t[d]-t[b]*t[c]) const float n=t[0]*det(4,5,7,8)-t[1]*det(3,5,6,8)+t[2]*det(3,4,6,7); float invT[3][3]={ {det(4,5,7,8)/n, det(2,1,8,7)/n, det(1,2,4,5)/n}, {det(5,3,8,6)/n, det(0,2,6,8)/n, det(2,0,5,3)/n}, {det(3,4,6,7)/n, det(1,0,7,6)/n, det(0,1,3,4)/n}, }; #undef det memcpy(inverse,invT,sizeof(invT)); return inverse; } static float* mul(float * restrict dst, const float * const restrict lhs, const unsigned nrows_lhs, const unsigned ncols_lhs, const float * const restrict rhs, const unsigned ncols_rhs){ unsigned i,j,k; for(k=0;k<nrows_lhs;++k) { for(j=0;j<ncols_rhs;++j) { float s=0.0f; for(i=0;i<ncols_lhs;++i) { s+=lhs[ncols_lhs*k+i]*rhs[ncols_rhs*i+j]; } dst[ncols_rhs*k+j]=s; } } return dst; } const struct mat_f32_api Matrixf={ i33, mul };
bsd-3-clause
unclecheese/silverstripe-docsviewer
code/tasks/RebuildLuceneDocsIndex.php
3556
<?php /** * Rebuilds the search indexes for the documentation pages. * * For the hourly cron rebuild use RebuildLuceneDocusIndex_Hourly * * @package docsviewer * @subpackage tasks */ class RebuildLuceneDocsIndex extends BuildTask { protected $title = "Rebuild Documentation Search Indexes"; protected $description = " Rebuilds the indexes used for the search engine in the docsviewer."; function run($request) { $this->rebuildIndexes(); } function rebuildIndexes($quiet = false) { require_once(DOCSVIEWER_PATH .'/thirdparty/markdown/markdown.php'); require_once 'Zend/Search/Lucene.php'; ini_set("memory_limit", -1); ini_set('max_execution_time', 0); Filesystem::makeFolder(DocumentationSearch::get_index_location()); // only rebuild the index if we have to. Check for either flush or the time write.lock.file // was last altered $lock = DocumentationSearch::get_index_location() .'/write.lock.file'; $lockFileFresh = (file_exists($lock) && filemtime($lock) > (time() - (60 * 60 * 24))); echo "Building index in ". DocumentationSearch::get_index_location() . PHP_EOL; if($lockFileFresh && !isset($_REQUEST['flush'])) { if(!$quiet) { echo "Index recently rebuilt. If you want to force reindex use ?flush=1"; } return true; } try { $index = Zend_Search_Lucene::open(DocumentationSearch::get_index_location()); $index->removeReference(); } catch (Zend_Search_Lucene_Exception $e) { // user_error($e); } try { $index = Zend_Search_Lucene::create(DocumentationSearch::get_index_location()); } catch(Zend_Search_Lucene_Exception $c) { user_error($c); } // includes registration $pages = DocumentationSearch::get_all_documentation_pages(); if($pages) { $count = 0; // iconv complains about all the markdown formatting // turn off notices while we parse $error = error_reporting(); error_reporting('E_ALL ^ E_NOTICE'); foreach($pages as $page) { $count++; if(!is_dir($page->getPath())) { $doc = new Zend_Search_Lucene_Document(); $content = $page->getMarkdown(); if($content) $content = Markdown($content); $entity = ($entity = $page->getEntity()) ? $entity->getTitle() : ""; $doc->addField(Zend_Search_Lucene_Field::Text('content', $content)); $doc->addField($titleField = Zend_Search_Lucene_Field::Text('Title', $page->getTitle())); $doc->addField($breadcrumbField = Zend_Search_Lucene_Field::Text('BreadcrumbTitle', $page->getBreadcrumbTitle())); $doc->addField(Zend_Search_Lucene_Field::Keyword('Version', $page->getVersion())); $doc->addField(Zend_Search_Lucene_Field::Keyword('Language', $page->getLang())); $doc->addField(Zend_Search_Lucene_Field::Keyword('Entity', $entity)); $doc->addField(Zend_Search_Lucene_Field::Keyword('Link', $page->getLink(false))); // custom boosts $titleField->boost = 3; $breadcrumbField->boost = 1.5; foreach(DocumentationSearch::$boost_by_path as $pathExpr => $boost) { if(preg_match($pathExpr, $page->getRelativePath())) $doc->boost = $boost; } $index->addDocument($doc); } if(!$quiet) echo "adding ". $page->getPath() ."\n"; } error_reporting($error); } $index->commit(); if(!$quiet) echo "complete."; } } /** * @package docsviewer * @subpackage tasks */ class RebuildLuceneDocusIndex_Hourly extends HourlyTask { function process() { $reindex = new RebuildLuceneDocusIndex(); $reindex->rebuildIndexes(true); } }
bsd-3-clause
AmiArt/treefrog-framework
tools/tmake/otamaconverter.h
671
#ifndef OTAMACONVERTER_H #define OTAMACONVERTER_H #include "erbconverter.h" #include <QDir> #include <QString> #include <TGlobal> class OtamaConverter { public: OtamaConverter(const QDir &output, const QDir &helpers, const QDir &partial); ~OtamaConverter(); bool convert(const QString &filePath, int trimMode) const; static QString convertToErb(const QString &html, const QString &otm, int trimMode); static QString fileSuffix() { return "html"; } static QString logicFileSuffix() { return "otm"; } private: ErbConverter erbConverter; T_DISABLE_COPY(OtamaConverter) T_DISABLE_MOVE(OtamaConverter) }; #endif // OTAMACONVERTER_H
bsd-3-clause
ric2b/Vivaldi-browser
update_notifier/thirdparty/wxWidgets/samples/widgets/checkbox.cpp
9600
///////////////////////////////////////////////////////////////////////////// // Program: wxWidgets Widgets Sample // Name: checkbox.cpp // Purpose: Part of the widgets sample showing wxCheckBox // Author: Dimitri Schoolwerth, Vadim Zeitlin // Created: 27 Sep 2003 // Copyright: (c) 2003 wxWindows team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ // declarations // ============================================================================ // ---------------------------------------------------------------------------- // headers // ---------------------------------------------------------------------------- // for compilers that support precompilation, includes "wx/wx.h". #include "wx/wxprec.h" // for all others, include the necessary headers #ifndef WX_PRECOMP #include "wx/app.h" #include "wx/log.h" #include "wx/bitmap.h" #include "wx/button.h" #include "wx/checkbox.h" #include "wx/radiobox.h" #include "wx/statbox.h" #include "wx/textctrl.h" #include "wx/sizer.h" #endif #include "widgets.h" #include "icons/checkbox.xpm" // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- // control ids enum { CheckboxPage_Reset = wxID_HIGHEST, CheckboxPage_ChangeLabel, CheckboxPage_Check, CheckboxPage_Uncheck, CheckboxPage_PartCheck, CheckboxPage_ChkRight, CheckboxPage_Checkbox }; enum { CheckboxKind_2State, CheckboxKind_3State, CheckboxKind_3StateUser }; // ---------------------------------------------------------------------------- // CheckBoxWidgetsPage // ---------------------------------------------------------------------------- class CheckBoxWidgetsPage : public WidgetsPage { public: CheckBoxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist); virtual wxWindow *GetWidget() const wxOVERRIDE { return m_checkbox; } virtual void RecreateWidget() wxOVERRIDE { CreateCheckbox(); } // lazy creation of the content virtual void CreateContent() wxOVERRIDE; protected: // event handlers void OnCheckBox(wxCommandEvent& event); void OnStyleChange(wxCommandEvent& event); void OnButtonReset(wxCommandEvent& event); void OnButtonChangeLabel(wxCommandEvent& event); void OnButtonCheck(wxCommandEvent&) { m_checkbox->SetValue(true); } void OnButtonUncheck(wxCommandEvent&) { m_checkbox->SetValue(false); } void OnButtonPartCheck(wxCommandEvent&) { m_checkbox->Set3StateValue(wxCHK_UNDETERMINED); } void Is3State(wxUpdateUIEvent& event) { event.Enable( m_checkbox->Is3State() ); } // reset the wxCheckBox parameters void Reset(); // (re)create the wxCheckBox void CreateCheckbox(); // the controls // ------------ // the controls to choose the checkbox style wxCheckBox *m_chkRight; wxRadioBox *m_radioKind; // the checkbox itself and the sizer it is in wxCheckBox *m_checkbox; wxSizer *m_sizerCheckbox; // the text entries for command parameters wxTextCtrl *m_textLabel; private: wxDECLARE_EVENT_TABLE(); DECLARE_WIDGETS_PAGE(CheckBoxWidgetsPage) }; // ---------------------------------------------------------------------------- // event tables // ---------------------------------------------------------------------------- wxBEGIN_EVENT_TABLE(CheckBoxWidgetsPage, WidgetsPage) EVT_CHECKBOX(CheckboxPage_Checkbox, CheckBoxWidgetsPage::OnCheckBox) EVT_BUTTON(CheckboxPage_Reset, CheckBoxWidgetsPage::OnButtonReset) EVT_BUTTON(CheckboxPage_ChangeLabel, CheckBoxWidgetsPage::OnButtonChangeLabel) EVT_BUTTON(CheckboxPage_Check, CheckBoxWidgetsPage::OnButtonCheck) EVT_BUTTON(CheckboxPage_Uncheck, CheckBoxWidgetsPage::OnButtonUncheck) EVT_BUTTON(CheckboxPage_PartCheck, CheckBoxWidgetsPage::OnButtonPartCheck) EVT_UPDATE_UI(CheckboxPage_PartCheck, CheckBoxWidgetsPage::Is3State) EVT_RADIOBOX(wxID_ANY, CheckBoxWidgetsPage::OnStyleChange) EVT_CHECKBOX(CheckboxPage_ChkRight, CheckBoxWidgetsPage::OnStyleChange) wxEND_EVENT_TABLE() // ============================================================================ // implementation // ============================================================================ #if defined(__WXUNIVERSAL__) #define FAMILY_CTRLS UNIVERSAL_CTRLS #else #define FAMILY_CTRLS NATIVE_CTRLS #endif IMPLEMENT_WIDGETS_PAGE(CheckBoxWidgetsPage, "CheckBox", FAMILY_CTRLS ); CheckBoxWidgetsPage::CheckBoxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist) : WidgetsPage(book, imaglist, checkbox_xpm) { } void CheckBoxWidgetsPage::CreateContent() { wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL); // left pane wxStaticBox *box = new wxStaticBox(this, wxID_ANY, "&Set style"); wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL); m_chkRight = CreateCheckBoxAndAddToSizer ( sizerLeft, "&Right aligned", CheckboxPage_ChkRight ); sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer static const wxString kinds[] = { "usual &2-state checkbox", "&3rd state settable by program", "&user-settable 3rd state", }; m_radioKind = new wxRadioBox(this, wxID_ANY, "&Kind", wxDefaultPosition, wxDefaultSize, WXSIZEOF(kinds), kinds, 1); sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5); wxButton *btn = new wxButton(this, CheckboxPage_Reset, "&Reset"); sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15); // middle pane wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, "&Operations"); wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL); sizerMiddle->Add(CreateSizerWithTextAndButton(CheckboxPage_ChangeLabel, "Change label", wxID_ANY, &m_textLabel), 0, wxALL | wxGROW, 5); sizerMiddle->Add(new wxButton(this, CheckboxPage_Check, "&Check it"), 0, wxALL | wxGROW, 5); sizerMiddle->Add(new wxButton(this, CheckboxPage_Uncheck, "&Uncheck it"), 0, wxALL | wxGROW, 5); sizerMiddle->Add(new wxButton(this, CheckboxPage_PartCheck, "Put in &3rd state"), 0, wxALL | wxGROW, 5); // right pane wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL); m_checkbox = new wxCheckBox(this, CheckboxPage_Checkbox, "&Check me!"); sizerRight->Add(0, 0, 1, wxCENTRE); sizerRight->Add(m_checkbox, 1, wxCENTRE); sizerRight->Add(0, 0, 1, wxCENTRE); sizerRight->SetMinSize(150, 0); m_sizerCheckbox = sizerRight; // save it to modify it later // the 3 panes panes compose the window sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10); sizerTop->Add(sizerMiddle, 1, wxGROW | wxALL, 10); sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10); // final initializations Reset(); SetSizer(sizerTop); } void CheckBoxWidgetsPage::Reset() { m_chkRight->SetValue(false); m_radioKind->SetSelection(CheckboxKind_2State); } void CheckBoxWidgetsPage::CreateCheckbox() { wxString label = m_checkbox->GetLabel(); size_t count = m_sizerCheckbox->GetChildren().GetCount(); for ( size_t n = 0; n < count; n++ ) { m_sizerCheckbox->Remove(0); } delete m_checkbox; int flags = GetAttrs().m_defaultFlags; if ( m_chkRight->IsChecked() ) flags |= wxALIGN_RIGHT; switch ( m_radioKind->GetSelection() ) { default: wxFAIL_MSG("unexpected radiobox selection"); wxFALLTHROUGH; case CheckboxKind_2State: flags |= wxCHK_2STATE; break; case CheckboxKind_3StateUser: flags |= wxCHK_ALLOW_3RD_STATE_FOR_USER; wxFALLTHROUGH; case CheckboxKind_3State: flags |= wxCHK_3STATE; break; } m_checkbox = new wxCheckBox(this, CheckboxPage_Checkbox, label, wxDefaultPosition, wxDefaultSize, flags); m_sizerCheckbox->Add(0, 0, 1, wxCENTRE); m_sizerCheckbox->Add(m_checkbox, 1, wxCENTRE); m_sizerCheckbox->Add(0, 0, 1, wxCENTRE); m_sizerCheckbox->Layout(); } // ---------------------------------------------------------------------------- // event handlers // ---------------------------------------------------------------------------- void CheckBoxWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event)) { Reset(); CreateCheckbox(); } void CheckBoxWidgetsPage::OnStyleChange(wxCommandEvent& WXUNUSED(event)) { CreateCheckbox(); } void CheckBoxWidgetsPage::OnButtonChangeLabel(wxCommandEvent& WXUNUSED(event)) { m_checkbox->SetLabel(m_textLabel->GetValue()); } void CheckBoxWidgetsPage::OnCheckBox(wxCommandEvent& event) { wxLogMessage("Test checkbox %schecked (value = %d).", event.IsChecked() ? "" : "un", (int)m_checkbox->Get3StateValue()); }
bsd-3-clause
ric2b/Vivaldi-browser
chromium/chrome/android/javatests/src/org/chromium/chrome/browser/autofill_assistant/AutofillAssistantPreferenceFragmentTest.java
13445
// Copyright 2020 The Chromium 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 org.chromium.chrome.browser.autofill_assistant; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import androidx.preference.Preference; import androidx.preference.PreferenceCategory; import androidx.test.filters.LargeTest; import org.junit.Test; import org.junit.runner.RunWith; import org.chromium.base.test.util.Feature; import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.settings.SettingsActivityTestRule; import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.util.browser.Features.DisableFeatures; import org.chromium.chrome.test.util.browser.Features.EnableFeatures; import org.chromium.components.browser_ui.settings.ChromeSwitchPreference; import org.chromium.content_public.browser.test.util.TestThreadUtils; /** * Tests for AutofillAssistantPreferenceFragment. */ @RunWith(ChromeJUnit4ClassRunner.class) public class AutofillAssistantPreferenceFragmentTest { private final SettingsActivityTestRule<AutofillAssistantPreferenceFragment> mSettingsActivityTestRule = new SettingsActivityTestRule<>(AutofillAssistantPreferenceFragment.class); private final SharedPreferencesManager mSharedPreferencesManager = SharedPreferencesManager.getInstance(); /** * Test: if the onboarding was never shown or it was shown and not accepted, the AA chrome * preference should not exist. * * Note: the presence of the {@link AutofillAssistantPreferenceFragment.PREF_AUTOFILL_ASSISTANT} * shared preference indicates whether the onboarding was accepted or not. */ @Test @LargeTest @Feature({"Sync"}) @EnableFeatures(AssistantFeatures.AUTOFILL_ASSISTANT_NAME) public void testAutofillAssistantNoPreferenceIfOnboardingNeverShown() { final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { assertFalse(prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_AUTOFILL_ASSISTANT) .isVisible()); }); } /** * Test: if the onboarding was accepted, the AA chrome preference should also exist. * * Note: the presence of the {@link AutofillAssistantPreferenceFragment.PREF_AUTOFILL_ASSISTANT} * shared preference indicates whether the onboarding was accepted or not. */ @Test @LargeTest @Feature({"Sync"}) @EnableFeatures(AssistantFeatures.AUTOFILL_ASSISTANT_NAME) public void testAutofillAssistantPreferenceShownIfOnboardingShown() { setAutofillAssistantSwitchValue(true); final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { assertTrue(prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_AUTOFILL_ASSISTANT) .isVisible()); }); } /** * Ensure that the "Autofill Assistant" setting is not shown when the feature is disabled. */ @Test @LargeTest @Feature({"Sync"}) @DisableFeatures(AssistantFeatures.AUTOFILL_ASSISTANT_NAME) public void testAutofillAssistantNoPreferenceIfFeatureDisabled() { setAutofillAssistantSwitchValue(true); final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { assertFalse(prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_AUTOFILL_ASSISTANT) .isVisible()); }); } /** * Ensure that the "Autofill Assistant" on/off switch works. */ @Test @LargeTest @Feature({"Sync"}) @EnableFeatures(AssistantFeatures.AUTOFILL_ASSISTANT_NAME) public void testAutofillAssistantSwitchOn() { TestThreadUtils.runOnUiThreadBlocking(() -> { setAutofillAssistantSwitchValue(true); }); final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { ChromeSwitchPreference autofillAssistantSwitch = (ChromeSwitchPreference) prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_AUTOFILL_ASSISTANT); assertTrue(autofillAssistantSwitch.isChecked()); autofillAssistantSwitch.performClick(); assertFalse(mSharedPreferencesManager.readBoolean( ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, true)); autofillAssistantSwitch.performClick(); assertTrue(mSharedPreferencesManager.readBoolean( ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, false)); }); } @Test @LargeTest @Feature({"Sync"}) @EnableFeatures({AssistantFeatures.AUTOFILL_ASSISTANT_NAME, AssistantFeatures.AUTOFILL_ASSISTANT_PROACTIVE_HELP_NAME}) @DisableFeatures(AssistantFeatures.AUTOFILL_ASSISTANT_DISABLE_PROACTIVE_HELP_TIED_TO_MSBB_NAME) public void testProactiveHelpDisabledIfMsbbDisabled() { final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { ChromeSwitchPreference proactiveHelpSwitch = (ChromeSwitchPreference) prefs.findPreference( AutofillAssistantPreferenceFragment .PREF_ASSISTANT_PROACTIVE_HELP_SWITCH); assertFalse(proactiveHelpSwitch.isEnabled()); Preference syncAndServicesLink = prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_GOOGLE_SERVICES_SETTINGS_LINK); assertNotNull(syncAndServicesLink); assertTrue(syncAndServicesLink.isVisible()); }); } @Test @LargeTest @Feature({"Sync"}) @EnableFeatures({AssistantFeatures.AUTOFILL_ASSISTANT_NAME, AssistantFeatures.AUTOFILL_ASSISTANT_PROACTIVE_HELP_NAME, AssistantFeatures.AUTOFILL_ASSISTANT_DISABLE_PROACTIVE_HELP_TIED_TO_MSBB_NAME}) public void testProactiveHelpNotLinkedToMsbbIfLinkDisabled() { final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { ChromeSwitchPreference proactiveHelpSwitch = (ChromeSwitchPreference) prefs.findPreference( AutofillAssistantPreferenceFragment .PREF_ASSISTANT_PROACTIVE_HELP_SWITCH); assertTrue(proactiveHelpSwitch.isEnabled()); Preference syncAndServicesLink = prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_GOOGLE_SERVICES_SETTINGS_LINK); assertNotNull(syncAndServicesLink); assertFalse(syncAndServicesLink.isVisible()); }); } @Test @LargeTest @Feature({"Sync"}) @EnableFeatures({AssistantFeatures.AUTOFILL_ASSISTANT_NAME, AssistantFeatures.AUTOFILL_ASSISTANT_PROACTIVE_HELP_NAME}) @DisableFeatures(AssistantFeatures.AUTOFILL_ASSISTANT_DISABLE_PROACTIVE_HELP_TIED_TO_MSBB_NAME) public void testProactiveHelpDisabledIfAutofillAssistantDisabled() { TestThreadUtils.runOnUiThreadBlocking(() -> { setAutofillAssistantSwitchValue(true); }); final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { ChromeSwitchPreference proactiveHelpSwitch = (ChromeSwitchPreference) prefs.findPreference( AutofillAssistantPreferenceFragment .PREF_ASSISTANT_PROACTIVE_HELP_SWITCH); Preference syncAndServicesLink = prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_GOOGLE_SERVICES_SETTINGS_LINK); assertFalse(proactiveHelpSwitch.isEnabled()); assertTrue(syncAndServicesLink.isVisible()); ChromeSwitchPreference autofillAssistantSwitch = (ChromeSwitchPreference) prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_AUTOFILL_ASSISTANT); autofillAssistantSwitch.performClick(); assertFalse(proactiveHelpSwitch.isEnabled()); assertFalse(syncAndServicesLink.isVisible()); }); } @Test @LargeTest @Feature({"Sync"}) @DisableFeatures(AssistantFeatures.AUTOFILL_ASSISTANT_PROACTIVE_HELP_NAME) public void testProactiveHelpInvisibleIfProactiveHelpDisabled() { final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { ChromeSwitchPreference proactiveHelpSwitch = (ChromeSwitchPreference) prefs.findPreference( AutofillAssistantPreferenceFragment .PREF_ASSISTANT_PROACTIVE_HELP_SWITCH); assertFalse(proactiveHelpSwitch.isVisible()); }); } @Test @LargeTest @Feature({"Sync"}) @DisableFeatures({AssistantFeatures.AUTOFILL_ASSISTANT_NAME, AssistantFeatures.AUTOFILL_ASSISTANT_PROACTIVE_HELP_NAME}) public void testWebAssistanceInvisibleIfAutofillAssistantCompletelyDisabled() { final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { PreferenceCategory webAssistanceCateogory = prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_WEB_ASSISTANCE_CATEGORY); assertFalse(webAssistanceCateogory.isVisible()); }); } @Test @LargeTest @Feature({"AssistantVoiceSearch"}) @EnableFeatures(ChromeFeatureList.OMNIBOX_ASSISTANT_VOICE_SEARCH) public void testEnhancedVoiceSearch_Enabled() { final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { PreferenceCategory assistantVoiceSearchCategory = prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_ASSISTANT_VOICE_SEARCH_CATEGORY); assertTrue(assistantVoiceSearchCategory.isVisible()); ChromeSwitchPreference assistantVoiceSearchEnabledSwitch = (ChromeSwitchPreference) prefs.findPreference( AutofillAssistantPreferenceFragment .PREF_ASSISTANT_VOICE_SEARCH_ENABLED_SWTICH); assertTrue(assistantVoiceSearchEnabledSwitch.isVisible()); assistantVoiceSearchEnabledSwitch.performClick(); assertTrue(mSharedPreferencesManager.readBoolean( ChromePreferenceKeys.ASSISTANT_VOICE_SEARCH_ENABLED, /* default= */ false)); }); } @Test @LargeTest @Feature({"AssistantVoiceSearch"}) @DisableFeatures(ChromeFeatureList.OMNIBOX_ASSISTANT_VOICE_SEARCH) public void testEnhancedVoiceSearch_Disabled() { final AutofillAssistantPreferenceFragment prefs = startAutofillAssistantPreferenceFragment(); TestThreadUtils.runOnUiThreadBlocking(() -> { PreferenceCategory assistantVoiceSearchCategory = prefs.findPreference( AutofillAssistantPreferenceFragment.PREF_ASSISTANT_VOICE_SEARCH_CATEGORY); assertFalse(assistantVoiceSearchCategory.isVisible()); ChromeSwitchPreference assistantVoiceSearchEnabledSwitch = (ChromeSwitchPreference) prefs.findPreference( AutofillAssistantPreferenceFragment .PREF_ASSISTANT_VOICE_SEARCH_ENABLED_SWTICH); assertFalse(assistantVoiceSearchEnabledSwitch.isVisible()); }); } private void setAutofillAssistantSwitchValue(boolean newValue) { SharedPreferencesManager.getInstance().writeBoolean( ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, newValue); } private AutofillAssistantPreferenceFragment startAutofillAssistantPreferenceFragment() { mSettingsActivityTestRule.startSettingsActivity(); return mSettingsActivityTestRule.getFragment(); } public boolean isAutofillAssistantSwitchOn() { return mSharedPreferencesManager.readBoolean( ChromePreferenceKeys.AUTOFILL_ASSISTANT_ENABLED, false); } }
bsd-3-clause
pullpulldondon/ThumbShift
os.html
23072
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/> <link rel="stylesheet" href="style.css" type="text/css" /> <script type="text/javascript"> <!-- document.onkeydown = function(e){ //alert(e.keyCode); //親指シフトキー処理 if(e.keyCode == 29){ thumbKeyPressed(1); retun; } if(e.keyCode == 28){ thumbKeyPressed(2); return; } //変換無変換キーがない場合はスペースキーでトグルする if(e.keyCode == 32){ thumbKeyPressed(shift == 2 ? 2 : shift+1); return; } if(e.keyCode == 8){ bsKeyPressed(); //ブラウザによるbsキーを無効に e.keyCode == 0; e.cancelBubble = true; return false; } if(e.keyCode == 'Q'.charCodeAt(0)) document.form1.textbox1.value += getChar(0, shift); if(e.keyCode == 'W'.charCodeAt(0)) document.form1.textbox1.value += getChar(1, shift); if(e.keyCode == 'E'.charCodeAt(0)) document.form1.textbox1.value += getChar(2, shift); if(e.keyCode == 'R'.charCodeAt(0)) document.form1.textbox1.value += getChar(3, shift); if(e.keyCode == 'T'.charCodeAt(0)) document.form1.textbox1.value += getChar(4, shift); if(e.keyCode == 'Y'.charCodeAt(0)) document.form1.textbox1.value += getChar(5, shift); if(e.keyCode == 'U'.charCodeAt(0)) document.form1.textbox1.value += getChar(6, shift); if(e.keyCode == 'I'.charCodeAt(0)) document.form1.textbox1.value += getChar(7, shift); if(e.keyCode == 'O'.charCodeAt(0)) document.form1.textbox1.value += getChar(8, shift); if(e.keyCode == 'P'.charCodeAt(0)) document.form1.textbox1.value += getChar(9, shift); //ipadだったら英字キーボード用の対応をする if(navigator.userAgent.indexOf("iPad") != -1){ if(e.keyCode == 219 /* @ */) document.form1.textbox1.value += getChar(10, shift); if(e.keyCode == 221 /* [ */) document.form1.textbox1.value += getChar(11, shift); } else{ if(e.keyCode == 192 /* @ */) document.form1.textbox1.value += getChar(10, shift); if(e.keyCode == 219 /* [ */) document.form1.textbox1.value += getChar(11, shift); } if(e.keyCode == 'A'.charCodeAt(0)) document.form1.textbox1.value += getChar(12, shift); if(e.keyCode == 'S'.charCodeAt(0)) document.form1.textbox1.value += getChar(13, shift); if(e.keyCode == 'D'.charCodeAt(0)) document.form1.textbox1.value += getChar(14, shift); if(e.keyCode == 'F'.charCodeAt(0)) document.form1.textbox1.value += getChar(15, shift); if(e.keyCode == 'G'.charCodeAt(0)) document.form1.textbox1.value += getChar(16, shift); if(e.keyCode == 'H'.charCodeAt(0)) document.form1.textbox1.value += getChar(17, shift); if(e.keyCode == 'J'.charCodeAt(0)) document.form1.textbox1.value += getChar(18, shift); if(e.keyCode == 'K'.charCodeAt(0)) document.form1.textbox1.value += getChar(19, shift); if(e.keyCode == 'L'.charCodeAt(0)) document.form1.textbox1.value += getChar(20, shift); if(navigator.userAgent.indexOf("iPad") != -1){ if(e.keyCode == 186 /* ; */) document.form1.textbox1.value += getChar(21, shift); if(e.keyCode == 222 /* : */) document.form1.textbox1.value += getChar(22, shift); //日本語キーボードの]は英字キーボードにはない //if(e.keyCode == 221 /* ] */) document.form1.textbox1.value += getChar(23, shift); } else{ if(e.keyCode == 187 /* ; */) document.form1.textbox1.value += getChar(21, shift); if(e.keyCode == 186 /* : */) document.form1.textbox1.value += getChar(22, shift); if(e.keyCode == 221 /* ] */) document.form1.textbox1.value += getChar(23, shift); } if(e.keyCode == 'Z'.charCodeAt(0)) document.form1.textbox1.value += getChar(24, shift); if(e.keyCode == 'X'.charCodeAt(0)) document.form1.textbox1.value += getChar(25, shift); if(e.keyCode == 'C'.charCodeAt(0)) document.form1.textbox1.value += getChar(26, shift); if(e.keyCode == 'V'.charCodeAt(0)) document.form1.textbox1.value += getChar(27, shift); if(e.keyCode == 'B'.charCodeAt(0)) document.form1.textbox1.value += getChar(28, shift); if(e.keyCode == 'N'.charCodeAt(0)) document.form1.textbox1.value += getChar(29, shift); if(e.keyCode == 'M'.charCodeAt(0)) document.form1.textbox1.value += getChar(30, shift); if(navigator.userAgent.indexOf("iPad") != -1){ if(e.keyCode == 188 /* , */) document.form1.textbox1.value += getChar(31, shift); if(e.keyCode == 190 /* . */) document.form1.textbox1.value += getChar(32, shift); if(e.keyCode == 191 /* / */) document.form1.textbox1.value += getChar(33, shift); //日本語キーボードの\は英字キーボードにはない //if(e.keyCode == 226 /* \ */) document.form1.textbox1.value += getChar(34, shift); } else{ if(e.keyCode == 188 /* , */) document.form1.textbox1.value += getChar(31, shift); if(e.keyCode == 190 /* . */) document.form1.textbox1.value += getChar(32, shift); if(e.keyCode == 191 /* / */) document.form1.textbox1.value += getChar(33, shift); if(e.keyCode == 226 /* \ */) document.form1.textbox1.value += getChar(34, shift); } thumbKeyPressed(shift); } function load(){ var useragent = navigator.userAgent; if(useragent.indexOf("Windows") == -1) return; /*for(var i=0;i<35;i++){ var button = document.getElementById("button"+i); button.addEventListener("click", function(){ alert(i); }, false); }*/ document.getElementById("button0").addEventListener("click", function(){ keyPressed(0); }, false); document.getElementById("button1").addEventListener("click", function(){ keyPressed(1); }, false); document.getElementById("button2").addEventListener("click", function(){ keyPressed(2); }, false); document.getElementById("button3").addEventListener("click", function(){ keyPressed(3); }, false); document.getElementById("button4").addEventListener("click", function(){ keyPressed(4); }, false); document.getElementById("button5").addEventListener("click", function(){ keyPressed(5); }, false); document.getElementById("button6").addEventListener("click", function(){ keyPressed(6); }, false); document.getElementById("button7").addEventListener("click", function(){ keyPressed(7); }, false); document.getElementById("button8").addEventListener("click", function(){ keyPressed(8); }, false); document.getElementById("button9").addEventListener("click", function(){ keyPressed(9); }, false); //document.getElementById("button10").addEventListener("click", function(){ keyPressed(10); }, false); //document.getElementById("button11").addEventListener("click", function(){ keyPressed(11); }, false); document.getElementById("button12").addEventListener("click", function(){ keyPressed(12); }, false); document.getElementById("button13").addEventListener("click", function(){ keyPressed(13); }, false); document.getElementById("button14").addEventListener("click", function(){ keyPressed(14); }, false); document.getElementById("button15").addEventListener("click", function(){ keyPressed(15); }, false); document.getElementById("button16").addEventListener("click", function(){ keyPressed(16); }, false); document.getElementById("button17").addEventListener("click", function(){ keyPressed(17); }, false); document.getElementById("button18").addEventListener("click", function(){ keyPressed(18); }, false); document.getElementById("button19").addEventListener("click", function(){ keyPressed(19); }, false); document.getElementById("button20").addEventListener("click", function(){ keyPressed(20); }, false); document.getElementById("button21").addEventListener("click", function(){ keyPressed(21); }, false); document.getElementById("button22").addEventListener("click", function(){ keyPressed(22); }, false); //document.getElementById("button23").addEventListener("click", function(){ keyPressed(23); }, false); document.getElementById("button24").addEventListener("click", function(){ keyPressed(24); }, false); document.getElementById("button25").addEventListener("click", function(){ keyPressed(25); }, false); document.getElementById("button26").addEventListener("click", function(){ keyPressed(26); }, false); document.getElementById("button27").addEventListener("click", function(){ keyPressed(27); }, false); document.getElementById("button28").addEventListener("click", function(){ keyPressed(28); }, false); document.getElementById("button29").addEventListener("click", function(){ keyPressed(29); }, false); document.getElementById("button30").addEventListener("click", function(){ keyPressed(30); }, false); document.getElementById("button31").addEventListener("click", function(){ keyPressed(31); }, false); document.getElementById("button32").addEventListener("click", function(){ keyPressed(32); }, false); document.getElementById("button33").addEventListener("click", function(){ keyPressed(33); }, false); document.getElementById("button34").addEventListener("click", function(){ keyPressed(34); }, false); document.getElementById("button35").addEventListener("click", function(){ keyPressed(35); }, false); document.getElementById("button36").addEventListener("click", function(){ keyPressed(36); }, false); document.getElementById("button37").addEventListener("click", function(){ keyPressed(37); }, false); document.getElementById("button38").addEventListener("click", function(){ keyPressed(38); }, false); document.getElementById("button39").addEventListener("click", function(){ keyPressed(39); }, false); document.getElementById("button40").addEventListener("click", function(){ keyPressed(40); }, false); document.getElementById("button41").addEventListener("click", function(){ keyPressed(41); }, false); document.getElementById("button42").addEventListener("click", function(){ keyPressed(42); }, false); document.getElementById("button43").addEventListener("click", function(){ keyPressed(43); }, false); document.getElementById("button44").addEventListener("click", function(){ keyPressed(44); }, false); document.getElementById("buttonBS").addEventListener("click", function(){ bsKeyPressed(); }, false); document.getElementById("lthumb").addEventListener("click", function(){ thumbKeyPressed(1); }, false); document.getElementById("rthumb").addEventListener("click", function(){ thumbKeyPressed(2); }, false); document.getElementById("space").addEventListener("click", function(){ spaceKeyPressed(); }, false); document.getElementById("buttonLF").addEventListener("click", function(){ lfKeyPressed(); }, false); } function copy(){ document.getElementById("textbox1").focus(); document.getElementById("textbox1").select(); } // 0 : Up, 1 : Left, 2 : Right var shift = 0; function keyPressed(n){ document.form1.textbox1.value += getChar(n, shift); thumbKeyPressed(shift); } function spaceKeyPressed(){ document.form1.textbox1.value += " "; } function lfKeyPressed(){ document.form1.textbox1.value += "\n"; } function bsKeyPressed(){ var str = document.form1.textbox1.value; document.form1.textbox1.value = str.slice(0, -1); } function thumbKeyPressed(x){ //var thumbP = document.getElementById("thumbP"); if(x == shift){ //thumbP.innerHTML="なし"; shift = 0; for(var i=0;i<45;i++){ if(i==10 || i==11 || i==23) continue; document.getElementById("button"+i).value = getChar(i, shift); } document.getElementById("lthumb").style.backgroundColor = "#FFFFFF"; document.getElementById("rthumb").style.backgroundColor = "#FFFFFF"; } else if(x == 1){ //thumbP.innerHTML="L"; shift = 1; for(var i=0;i<45;i++){ if(i==10 || i==11 || i==23) continue; document.getElementById("button"+i).value = getChar(i, shift); } document.getElementById("lthumb").style.backgroundColor = "#888888"; document.getElementById("rthumb").style.backgroundColor = "#FFFFFF"; } else if(x == 2){ //thumbP.innerHTML="R"; shift = 2; for(var i=0;i<45;i++){ if(i==10 || i==11 || i==23) continue; document.getElementById("button"+i).value = getChar(i, shift); } document.getElementById("lthumb").style.backgroundColor = "#FFFFFF"; document.getElementById("rthumb").style.backgroundColor = "#888888"; } } function getChar(n, shift){ if(shift==0){ if(n==0) return"。"; if(n==1) return"か"; if(n==2) return"た"; if(n==3) return"こ"; if(n==4) return"さ"; if(n==5) return"ら"; if(n==6) return"ち"; if(n==7) return"く"; if(n==8) return"つ"; if(n==9) return","; if(n==10) return"@"; if(n==11) return"["; if(n==12) return"う"; if(n==13) return"し"; if(n==14) return"て"; if(n==15) return"け"; if(n==16) return"せ"; if(n==17) return"は"; if(n==18) return"と"; if(n==19) return"き"; if(n==20) return"い"; if(n==21) return"ん"; if(n==22) return"、"; if(n==23) return"]"; if(n==24) return"."; if(n==25) return"ひ"; if(n==26) return"す"; if(n==27) return"ふ"; if(n==28) return"へ"; if(n==29) return"め"; if(n==30) return"そ"; if(n==31) return"ね"; if(n==32) return"ほ"; if(n==33) return"・"; if(n==34) return"¥"; if(n==35) return"1"; if(n==36) return"2"; if(n==37) return"3"; if(n==38) return"4"; if(n==39) return"5"; if(n==40) return"6"; if(n==41) return"7"; if(n==42) return"8"; if(n==43) return"9"; if(n==44) return"0"; } if(shift==1){ if(n==0) return"ぁ"; if(n==1) return"え"; if(n==2) return"り"; if(n==3) return"ゃ"; if(n==4) return"れ"; if(n==5) return"ぱ"; if(n==6) return"ぢ"; if(n==7) return"ぐ"; if(n==8) return"づ"; if(n==9) return"ぴ"; if(n==10) return"@"; if(n==11) return"["; if(n==12) return"を"; if(n==13) return"あ"; if(n==14) return"な"; if(n==15) return"ゅ"; if(n==16) return"も"; if(n==17) return"ば"; if(n==18) return"ど"; if(n==19) return"ぎ"; if(n==20) return"ぽ"; if(n==21) return";"; if(n==22) return":"; if(n==23) return"]"; if(n==24) return"ぅ"; if(n==25) return"ー"; if(n==26) return"ろ"; if(n==27) return"や"; if(n==28) return"ぃ"; if(n==29) return"ぷ"; if(n==30) return"ぞ"; if(n==31) return"ぺ"; if(n==32) return"ぼ"; if(n==33) return"゛"; if(n==34) return"¥"; if(n==35) return"1"; if(n==36) return"2"; if(n==37) return"3"; if(n==38) return"4"; if(n==39) return"5"; if(n==40) return"6"; if(n==41) return"7"; if(n==42) return"8"; if(n==43) return"9"; if(n==44) return"0"; } if(shift==2){ if(n==0) return"゜"; if(n==1) return"が"; if(n==2) return"だ"; if(n==3) return"ご"; if(n==4) return"ざ"; if(n==5) return"よ"; if(n==6) return"に"; if(n==7) return"る"; if(n==8) return"ま"; if(n==9) return"ぇ"; if(n==10) return"@"; if(n==11) return"["; if(n==12) return"ヴ"; if(n==13) return"じ"; if(n==14) return"で"; if(n==15) return"げ"; if(n==16) return"ぜ"; if(n==17) return"み"; if(n==18) return"お"; if(n==19) return"の"; if(n==20) return"ょ"; if(n==21) return"っ"; if(n==22) return"、"; if(n==23) return"]"; if(n==24) return"."; if(n==25) return"び"; if(n==26) return"ず"; if(n==27) return"ぶ"; if(n==28) return"べ"; if(n==29) return"ぬ"; if(n==30) return"ゆ"; if(n==31) return"む"; if(n==32) return"わ"; if(n==33) return"ぉ"; if(n==34) return"¥"; if(n==35) return"1"; if(n==36) return"2"; if(n==37) return"3"; if(n==38) return"4"; if(n==39) return"5"; if(n==40) return"6"; if(n==41) return"7"; if(n==42) return"8"; if(n==43) return"9"; if(n==44) return"0"; } } //--> </script> </head> <body onLoad="load()"> <!-- p id="thumbP">なし</p --> <p>理由なきタイトル<input type="text"></p> <form name="form1"> <table style="width:100%;" border="1"> <tr> <td><textarea id="textbox1" rows="5" style="width:100%;"></textarea></td> <!-- td><input type="button" value="コピー" style="width:100%; height:100%;" onClick="copy()" /></td --> </tr> </table> <!-- input type="button" value="コピー" style="" onTouchStart="copy()" / --> </form> <table class="keyboard" border="1"> <tr> <td><input class="key" type="button" value="1" id="button35" onTouchStart="keyPressed(35)" /></td> <td><input class="key" type="button" value="2" id="button36" onTouchStart="keyPressed(36)" /></td> <td><input class="key" type="button" value="3" id="button37" onTouchStart="keyPressed(37)" /></td> <td><input class="key" type="button" value="4" id="button38" onTouchStart="keyPressed(38)" /></td> <td><input class="key" type="button" value="5" id="button39" onTouchStart="keyPressed(39)" /></td> <td><input class="key" type="button" value="6" id="button40" onTouchStart="keyPressed(40)" /></td> <td><input class="key" type="button" value="7" id="button41" onTouchStart="keyPressed(41)" /></td> <td><input class="key" type="button" value="8" id="button42" onTouchStart="keyPressed(42)" /></td> <td><input class="key" type="button" value="9" id="button43" onTouchStart="keyPressed(43)" /></td> <td><input class="key" type="button" value="0" id="button44" onTouchStart="keyPressed(44)" /></td> <!-- td><input class="key" type="button" value="-" id="button10" onTouchStart="keyPressed(10)" /></td --> <!-- td><input class="key" type="button" value="\" id="button11" onTouchStart="keyPressed(11)" /></td --> <td><input class="key" type="button" value="BS" id="buttonBS" onTouchStart="bsKeyPressed()" /></td> </tr> <tr> <td><input class="key" type="button" value="。" id="button0" onTouchStart="keyPressed(0)" /></td> <td><input class="key" type="button" value="か" id="button1" onTouchStart="keyPressed(1)" /></td> <td><input class="key" type="button" value="た" id="button2" onTouchStart="keyPressed(2)" /></td> <td><input class="key" type="button" value="こ" id="button3" onTouchStart="keyPressed(3)" /></td> <td><input class="key" type="button" value="さ" id="button4" onTouchStart="keyPressed(4)" /></td> <td><input class="key" type="button" value="ら" id="button5" onTouchStart="keyPressed(5)" /></td> <td><input class="key" type="button" value="ち" id="button6" onTouchStart="keyPressed(6)" /></td> <td><input class="key" type="button" value="く" id="button7" onTouchStart="keyPressed(7)" /></td> <td><input class="key" type="button" value="つ" id="button8" onTouchStart="keyPressed(8)" /></td> <td><input class="key" type="button" value="," id="button9" onTouchStart="keyPressed(9)" /></td> <!-- td><input class="key" type="button" value="@" id="button10" onTouchStart="keyPressed(10)" /></td --> <td><input class="key" type="button" value="改行" id="buttonLF" onTouchStart="lfKeyPressed()" /></td> <!-- td><input class="key" type="button" value="[" id="button11" onTouchStart="keyPressed(11)" /></td --> </tr> <tr> <td><input class="key" type="button" value="う" id="button12" onTouchStart="keyPressed(12)" /></td> <td><input class="key" type="button" value="し" id="button13" onTouchStart="keyPressed(13)" /></td> <td><input class="key" type="button" value="て" id="button14" onTouchStart="keyPressed(14)" /></td> <td><input class="key" type="button" value="け" id="button15" onTouchStart="keyPressed(15)" /></td> <td><input class="key" type="button" value="せ" id="button16" onTouchStart="keyPressed(16)" /></td> <td><input class="key" type="button" value="は" id="button17" onTouchStart="keyPressed(17)" /></td> <td><input class="key" type="button" value="と" id="button18" onTouchStart="keyPressed(18)" /></td> <td><input class="key" type="button" value="き" id="button19" onTouchStart="keyPressed(19)" /></td> <td><input class="key" type="button" value="い" id="button20" onTouchStart="keyPressed(20)" /></td> <td><input class="key" type="button" value="ん" id="button21" onTouchStart="keyPressed(21)" /></td> <td><input class="key" type="button" value="、" id="button22" onTouchStart="keyPressed(22)" /></td> <!-- td><input class="key" type="button" value="]" id="button23" onTouchStart="keyPressed(23)" /></td --> </tr> <tr> <td><input class="key" type="button" value="." id="button24" onTouchStart="keyPressed(24)" /></td> <td><input class="key" type="button" value="ひ" id="button25" onTouchStart="keyPressed(25)" /></td> <td><input class="key" type="button" value="す" id="button26" onTouchStart="keyPressed(26)" /></td> <td><input class="key" type="button" value="ふ" id="button27" onTouchStart="keyPressed(27)" /></td> <td><input class="key" type="button" value="へ" id="button28" onTouchStart="keyPressed(28)" /></td> <td><input class="key" type="button" value="め" id="button29" onTouchStart="keyPressed(29)" /></td> <td><input class="key" type="button" value="そ" id="button30" onTouchStart="keyPressed(30)" /></td> <td><input class="key" type="button" value="ね" id="button31" onTouchStart="keyPressed(31)" /></td> <td><input class="key" type="button" value="ほ" id="button32" onTouchStart="keyPressed(32)" /></td> <td><input class="key" type="button" value="・" id="button33" onTouchStart="keyPressed(33)" /></td> <td><input class="key" type="button" value="¥" id="button34" onTouchStart="keyPressed(34)" /></td> <!-- td><input class="key" type="button" value="BS" id="buttonBS" onTouchStart="bsKeyPressed()" /></td --> </tr> <tr> <td colspan="5"><input class="thumbkey" type="button" value="左親指" id="lthumb" onTouchStart="thumbKeyPressed(1)" /></td> <td colspan="5"><input class="thumbkey" type="button" value="右親指" id="rthumb" onTouchStart="thumbKeyPressed(2)" /></td> <td colspan="2"><input class="thumbkey" type="button" value="空白" id="space" onTouchStart="spaceKeyPressed()" /></td> </tr> </body> </html>
bsd-3-clause
noinia/hsync-server
src/HSync/Server/Handler/API.hs
5429
module HSync.Server.Handler.API where import Control.Lens import HSync.Common.API import qualified HSync.Common.StorageTree as ST import HSync.Server.Import import HSync.Common.Header import HSync.Common.Zip import HSync.Server.LocalAuth(validateUser) import HSync.Server.Notifications import HSync.Server.Handler.AcidUtils import Data.Maybe(fromJust) import Data.Aeson(encode) import qualified Data.Conduit.List as C import qualified Data.Text as T import qualified Data.Foldable as F import qualified System.FilePath as FP -------------------------------------------------------------------------------- postAPILoginR :: APIHandler Value postAPILoginR = lift $ do mu <- lookupTypedHeader HUserName mpw <- fmap hashPassword <$> lookupTypedHeader HPassword b <- validateUser' mu mpw when b $ setCreds False $ Creds "PostAPILoginR" ((fromJust mu)^.unUserName) [] return $ toJSON b where validateUser' mu mpw = fromMaybe (pure False) $ validateUser <$> mu <*> mpw -------------------------------------------------------------------------------- getListenNowR :: RealmId -> Path -> APIHandler TypedContent getListenNowR ri p = lift $ respondWithSource (notificationsFor ri p) getListenR :: DateTime -> RealmId -> Path -> APIHandler TypedContent getListenR d ri p = lift $ respondWithSource (notificationsAsOf d ri p) -- | Given a function to produce a source of a's (that can be encoded as JSON). -- Respond with this source respondWithSource :: ToJSON a => Handler (Source Handler a) -> Handler TypedContent respondWithSource mkSource = do s <- mkSource respondSource typePlain (s $= C.map encode $= awaitForever sendChunk') where sendChunk' x = sendChunk x >> sendFlush -------------------------------------------------------------------------------- getCurrentRealmR :: RealmId -> Path -> APIHandler Value getCurrentRealmR ri p = do mr <- lift . queryAcid $ Access ri p case mr of Nothing -> notFound Just node -> pure . toJSON . current' $ node getDownloadR :: RealmId -> FileKind -> Path -> APIHandler TypedContent getDownloadR _ NonExistent _ = notFound getDownloadR ri Directory p = lift $ queryAcid (Access ri p) >>= \case Nothing -> notFound Just node -> do let ps = mapMaybe toPath . ST.flatten . current' $ node fps <- mapM getFPs ps addTypedHeader HFileKind Directory addHeader "Content-Disposition" $ mconcat [ "attachment; filename=\"" , _unFileName $ fileNameOf p, ".zip\"" ] respondSource typeOctet (readArchive fps $= awaitForever sendChunk) where -- toPath :: _ -> Maybe (Path, Signature) toPath (n,(_,x)) = (Path $ F.toList n,) <$> x^?fileKind.signature getFPs (p',s) = (f p',) <$> getFilePath ri p' s f (Path ps) = FP.joinPath $ map (\n -> T.unpack $ n^.unFileName) ps getDownloadR ri fk@(File s) p = addTypedHeader HFileKind fk >> getFileR ri s p getFileR :: RealmId -> Signature -> Path -> APIHandler TypedContent getFileR ri s p = do fp <- lift $ getFilePath ri p s sendFile (contentTypeOf p) fp getDownloadCurrentR :: RealmId -> Path -> APIHandler TypedContent getDownloadCurrentR ri p = do mr <- lift . queryAcid $ Access ri p case (^.nodeData.headVersionLens.fileKind) <$> mr of Nothing -> notFound Just fk -> getDownloadR ri fk p -------------------------------------------------------------------------------- postCreateDirR :: ClientName -> RealmId -> Path -> APIHandler Value postCreateDirR cn ri p = toJSON <$> lift (withClientId cn $ \ci -> createDirectory ci ri p NonExistent) postStoreFileR :: ClientName -> RealmId -> FileKind -> Path -> APIHandler Value postStoreFileR _ _ Directory _ = lift $ invalidArgs ["Cannot replace a directory by a file"] postStoreFileR cn ri fk p = toJSON <$> lift (withClientId cn $ \ci -> addFile ci ri p fk rawRequestBody) -------------------------------------------------------------------------------- deleteDeleteR :: ClientName -> RealmId -> FileKind -> Path -> APIHandler Value deleteDeleteR _ _ NonExistent _ = reportError_ "Nothing to delete" deleteDeleteR cn ri fk p = toJSON <$> lift (withClientId cn $ \ci -> deleteFileOrDir ci ri p fk) reportError :: Text -> Either ErrorMessage (FileVersion (Maybe ClientName)) reportError = Left reportError_ :: Monad m => Text -> m Value reportError_ = pure . toJSON . reportError -- typedText typedText :: Text -> TypedContent typedText = toTypedContent typedText_ :: Monad m => Text -> m TypedContent typedText_ = return . typedText
bsd-3-clause
axkibe/node-vtk
wrappers/8.1.1/vtkDataObjectAlgorithmWrap.h
1591
/* this file has been autogenerated by vtkNodeJsWrap */ /* editing this might proof futile */ #ifndef NATIVE_EXTENSION_VTK_VTKDATAOBJECTALGORITHMWRAP_H #define NATIVE_EXTENSION_VTK_VTKDATAOBJECTALGORITHMWRAP_H #include <nan.h> #include <vtkSmartPointer.h> #include <vtkDataObjectAlgorithm.h> #include "vtkAlgorithmWrap.h" #include "../../plus/plus.h" class VtkDataObjectAlgorithmWrap : public VtkAlgorithmWrap { public: using Nan::ObjectWrap::Wrap; static void Init(v8::Local<v8::Object> exports); static void InitPtpl(); static void ConstructorGetter( v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info); VtkDataObjectAlgorithmWrap(vtkSmartPointer<vtkDataObjectAlgorithm>); VtkDataObjectAlgorithmWrap(); ~VtkDataObjectAlgorithmWrap( ); static Nan::Persistent<v8::FunctionTemplate> ptpl; private: static void New(const Nan::FunctionCallbackInfo<v8::Value>& info); static void AddInputData(const Nan::FunctionCallbackInfo<v8::Value>& info); static void GetInput(const Nan::FunctionCallbackInfo<v8::Value>& info); static void GetOutput(const Nan::FunctionCallbackInfo<v8::Value>& info); static void NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info); static void SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info); static void SetInputData(const Nan::FunctionCallbackInfo<v8::Value>& info); static void SetOutput(const Nan::FunctionCallbackInfo<v8::Value>& info); #ifdef VTK_NODE_PLUS_VTKDATAOBJECTALGORITHMWRAP_CLASSDEF VTK_NODE_PLUS_VTKDATAOBJECTALGORITHMWRAP_CLASSDEF #endif }; #endif
bsd-3-clause
ITA-Solar/helita
helita/obs/iris_util.py
9925
""" Set of utility programs for IRIS. """ import os import re import io import numpy as np import pandas as pd from datetime import datetime, timedelta from glob import glob # pylint: disable=F0401,E0611,E1103 from urllib.request import urlopen from urllib.parse import urljoin, urlparse from urllib.error import HTTPError, URLError def iris_timeline_parse(timeline_file): """ Parses an IRIS timeline file (SCI format) into a structured array. This version outputs a strucured array instead of a pandas DataSet. Parameters ---------- timeline_file - string Filename with timeline file, or URL to the file. Returns ------- result - pandas.DataFrame DataFrame with timeline. """ from sunpy.time import parse_time data = [] slews = [] curr_slew = np.array([np.nan, np.nan]) line_pat = re.compile('.+OBSID=.+rpt.+endtime', re.IGNORECASE) slew_pat = re.compile('.+I_EVENT_MESSAGE.+MSG="SLEW*', re.IGNORECASE) if urlparse(timeline_file).netloc == '': # local file file_obj = open(timeline_file, 'r') else: # network location try: tmp = urlopen(timeline_file).read() file_obj = io.StringIO(tmp) except (HTTPError, URLError): raise EOFError(('iris_timeline_parse: could not open the ' 'following file:\n' + timeline_file)) for line in file_obj: if slew_pat.match(line): tmp = line.split('=')[1].replace('"', '').strip('SLEW_').split('_') curr_slew = np.array(tmp).astype('f') if line_pat.match(line): data.append(line.replace('//', '').replace(' x ', ', ').strip()) slews.append(curr_slew) # include most up to date slew file_obj.close() if len(data) == 0: raise EOFError(('iris_timeline_parse: could not find any' ' observations in:\n' + str(timeline_file))) arr_type = [('date_obs', 'datetime64[us]'), ('date_end', 'datetime64[us]'), ('obsid', 'i8'), ('repeats', 'i4'), ('duration', 'f'), ('size', 'f'), ('description', '|S200'), ('xpos', 'f'), ('ypos', 'f'), ('timeline_name', '|S200')] result = np.zeros(len(data), dtype=arr_type) result['timeline_name'] = timeline_file for i, line in enumerate(data): date_tmp = line.split()[0] if date_tmp[-2:] == '60': # deal with non-compliant second formats date_tmp = date_tmp[:-2] + '59.999999' result[i]['date_obs'] = parse_time(date_tmp) tmp = line.replace(' Mbits, end', ', end') # Remove new Mbits size str tmp = tmp.split('desc=') result[i]['description'] = tmp[1] tmp = tmp[0] tmp = [k.split('=')[-1] for k in ' '.join(tmp.split()[1:]).split(',')] result[i]['obsid'] = int(tmp[0]) result[i]['repeats'] = int(tmp[1]) result[i]['duration'] = float(tmp[2][:-1]) result[i]['size'] = float(tmp[3]) tmp = tmp[4].split() result[i]['date_end'] = parse_time(date_tmp[:9] + tmp[-1]) + \ timedelta(days=int(tmp[0].strip('+'))) result[i]['xpos'] = slews[i][0] result[i]['ypos'] = slews[i][1] return pd.DataFrame(result) # order by date_obs def get_iris_timeline(date_start, date_end, path=None, fmt='%Y/%m/%d', pattern='.*IRIS_science_timeline.+txt'): """ Gets IRIS timelines for a given time period. """ if path is None: path = ('http://iris.lmsal.com/health-safety/timeline/' 'iris_tim_archive/') print('Locating files...') file_obj = FileCrawler(date_start, date_end, path, pattern, fmt) result = pd.DataFrame() for tfile in file_obj.files: try: print('Parsing:\n' + tfile) timeline = iris_timeline_parse(tfile) result = result.append(timeline) except EOFError: print('get_iris_timeline: could not read timeline data from:\n' + tfile) return result def get_iris_files(date_start, date_end, pattern='iris.*.fits', base='level1', path='/Users/tiago/data/IRIS/data/'): """ Gets list of IRIS observations for a given time period. Parameters ---------- date_start : str or datetime object Starting date to search date_end : str or datetime object Ending date to search path : str Base path to look into pattern : str Regular expression used to match file names. Returns ------- files : list List of strings with matching file names. """ file_path = os.path.join(path, base) file_obj = FileCrawler(date_start, date_end, file_path, pattern, fmt='%Y/%m/%d/H%H%M') return file_obj.files class FileCrawler(object): """ Crawls through file names in a local or remote (http) path. Parameters ---------- date_start : str or datetime object Starting date to search date_end : str or datetime object Ending date to search path : str Base path to look into pattern : str Regular expression used to match file names. recursive: bool If True, will recursively search subdirectories of dates. Attributes ---------- date_start : str or datetime object Starting date given as input date_end : str or datetime object Ending date given as input paths : list List of file paths given the supplied dates files : list List of file names given the supplied path, dates, and pattern Methods ------- get_remote_paths(date_start, date_end, path, fmt='%Y%m%d') Finds existing remote paths within specified dates in path, given fmt. get_remote_files(path, pattern) Finds existing remote files within specified path matching pattern. """ def __init__(self, date_start, date_end, path, pattern, fmt='%Y%m%d', verbose=False): self.date_start = date_start self.date_end = date_end self.paths = self.get_paths(date_start, date_end, path, fmt) if verbose: print('Found the following paths:') for item in self.paths: print(item) self.files = [] for item in self.paths: self.files += self.get_files(item, pattern) if verbose: print('Found the following files:') for item in self.files: print(item) @classmethod def get_paths(cls, date_start, date_end, path, fmt='%Y%m%d'): """ Gets paths within specified date range. Parameters ---------- date_start : str or datetime object Starting date to search date_end : str or datetime object Ending date to search path : str Base path where to look for locations (if starts with http, remote search will be done) format : str datetime format string for date in directories. Returns ------- dates - list List with path locations (local directories or remote paths) """ from sunpy.time import parse_time dates = [] date_start = parse_time(date_start) date_end = parse_time(date_end) curr = date_start if '%H' in fmt: incr = [0, 1] # increment only hours else: incr = [1, 0] # increment only days if urlparse(path).netloc == '': # local file while curr <= date_end: curr_path = os.path.join(path, datetime.strftime(curr, fmt)) curr += timedelta(days=incr[0], hours=incr[1]) if os.path.isdir(curr_path): dates.append(curr_path) else: # network location while curr <= date_end: curr_path = urljoin(path, datetime.strftime(curr, fmt) + '/') curr += timedelta(days=incr[0], hours=incr[1]) try: urlopen(curr_path) dates.append(curr_path) except (HTTPError, URLError): continue return dates @classmethod def get_files(cls, path, pattern): """ Obtains local or remote files patching a pattern. Parameters ---------- path : str Local directory or remote URL (e.g. 'http://www.google.com/test/') pattern : str Regular expression to be matched in href link names. Returns ------- files : list List of strings. Each string has the path for the files matching the pattern (and are made sure exist). .. todo:: add recursive option, add option for FTP """ from bs4 import BeautifulSoup files = [] pat_re = re.compile(pattern, re.IGNORECASE) if urlparse(path).scheme == '': # local file all_files = glob(path + '/*') for item in all_files: if pat_re.match(item) and os.path.isfile(item): files.append(item) elif urlparse(path).scheme == 'http': soup = BeautifulSoup(urlopen(path).read()) for link in soup.find_all('a'): if pat_re.match(link.get('href')): file_url = urljoin(path, link.get('href')) try: # Add only links that exist urlopen(file_url) files.append(file_url) except (HTTPError, URLError): pass elif urlparse(path).scheme == 'ftp': raise NotImplementedError('ftp not yet supported...') return files
bsd-3-clause
reginell/bsuir
README.md
151
# Education in BSUIR Here are my education projects. . -- bachelor/cpp # C++ education projects. -- bachelor/csharp # C# education projects.
bsd-3-clause
juhovuori/builder
main_test.go
1050
package main import ( "os" "os/exec" "testing" ) // TestMainSuccess tests main function in a separate process using a trick from // https://talks.golang.org/2014/testing.slide#1 func TestMainSuccess(t *testing.T) { if os.Getenv("TEST_MAIN_FUNC") == "1" { os.Args = []string{"", "nop"} main() return } cmd := exec.Command(os.Args[0], "-test.run=TestMainSuccess") cmd.Env = append(os.Environ(), "TEST_MAIN_FUNC=1") err := cmd.Run() if e, ok := err.(*exec.ExitError); ok && !e.Success() { t.Fatalf("process ran with err %v, want exit status 0", err) } } // TestMainFailure tests main function in a separate process using a trick from // https://talks.golang.org/2014/testing.slide#1 func TestMainFailure(t *testing.T) { if os.Getenv("TEST_MAIN_FUNC") == "1" { os.Args = []string{"", "fail"} main() return } cmd := exec.Command(os.Args[0], "-test.run=TestMainFailure") cmd.Env = append(os.Environ(), "TEST_MAIN_FUNC=1") err := cmd.Run() if err == nil { t.Fatalf("process ran with err %v, want exit status 1", err) } }
bsd-3-clause
MattiasLiljeson/Amalgamation
Projects/Gameplay/Src/AudioListenerSystem.cpp
2950
#include "AudioListenerSystem.h" #include "AudioBackendSystem.h" #include "AudioListener.h" #include "Transform.h" #include "SoundOrientation.h" #include "MeshOffsetTransform.h" AudioListenerSystem::AudioListenerSystem(AudioBackendSystem* p_audioBackend) : EntitySystem(SystemType::AudioListenerSystem, 2, ComponentType::Transform, ComponentType::AudioListener) { m_audioBackend = p_audioBackend; m_listener = SoundOrientation(); } AudioListenerSystem::~AudioListenerSystem() { } void AudioListenerSystem::processEntities( const vector<Entity*>& p_entities ) { if(!p_entities.empty()) { AudioListener* audioListener = static_cast<AudioListener*>( p_entities[0]->getComponent( ComponentType::AudioListener)); Transform* trans = static_cast<Transform*>( p_entities[0]->getComponent( ComponentType::Transform ) ); MeshOffsetTransform* offsetTrans = static_cast<MeshOffsetTransform*>( p_entities[0]->getComponent( ComponentType::MeshOffsetTransform )); if(offsetTrans){ AglMatrix worldTransform = offsetTrans->offset.inverse()*trans->getMatrix(); m_listener.listenerOrientFront = worldTransform.GetForward(); m_listener.listenerOrientTop = worldTransform.GetUp(); m_listener.listenerPos = worldTransform.GetTranslation(); } else{ m_listener.listenerPos = trans->getTranslation(); m_listener.listenerOrientFront = trans->getMatrix().GetForward(); m_listener.listenerOrientTop = trans->getMatrix().GetUp(); } /************************************************************************/ /* HACK:!!!THERE IS NO VELOCITY!!! */ /************************************************************************/ m_listener.listenerVelocity = AglVector3::zero(); m_audioBackend->updateListener( m_listener ); m_audioBackend->updateListenerVolume( audioListener->getListenerVolume() ); } } SoundOrientation* AudioListenerSystem::getListenerOrientation() { return &m_listener; } void AudioListenerSystem::initialize() { AntTweakBarWrapper::getInstance()->addReadOnlyVariable(AntTweakBarWrapper::OVERALL, "ListenerPosX", TwType::TW_TYPE_FLOAT, &m_listener.listenerPos.x, "group=Ship"); AntTweakBarWrapper::getInstance()->addReadOnlyVariable(AntTweakBarWrapper::OVERALL, "ListenerPosY", TwType::TW_TYPE_FLOAT, &m_listener.listenerPos.y, "group=Ship"); AntTweakBarWrapper::getInstance()->addReadOnlyVariable(AntTweakBarWrapper::OVERALL, "ListenerPosZ", TwType::TW_TYPE_FLOAT, &m_listener.listenerPos.z, "group=Ship"); } void AudioListenerSystem::inserted( Entity* p_entity ) { AudioListener* audioListener = static_cast<AudioListener*>( p_entity->getComponent( ComponentType::AudioListener)); AntTweakBarWrapper::getInstance()->modifyTheRefreshRate(AntTweakBarWrapper::SOUND,0.1f); AntTweakBarWrapper::getInstance()->addWriteVariable(AntTweakBarWrapper::SOUND, "MasterVolume", TwType::TW_TYPE_FLOAT, audioListener->getMasterVolumeRef(), "step=0.01f min=0 max=1"); }
bsd-3-clause
BlokasLabs/modep
stage5/17-mtc/01-run-chroot.sh
459
#!/bin/bash -e PLUGIN=mtc.lv2 GIT_URI="https://github.com/BlokasLabs/${PLUGIN}" TMP_DIR=/tmp/${PLUGIN} rm -rf ${TMP_DIR} git clone --depth 1 ${GIT_URI} ${TMP_DIR} pushd ${TMP_DIR} export CC=arm-linux-gnueabihf-gcc export CXX=arm-linux-gnueabihf-g++ export LD=arm-linux-gnueabihf-gcc export STRIP=arm-linux-gnueabihf-strip export OPTIMIZATIONS="-fno-finite-math-only" export MOD=1 export LV2DIR=${LV2_DIR} make -j4 make install popd rm -rf ${TMP_DIR}
bsd-3-clause
stcorp/legato
legato/registry.py
987
from __future__ import absolute_import, division, print_function _TRIGGERS = {} def register(tpe, start, stop, join): def decorator(f): _TRIGGERS[tpe] = { "parser": f, "start": start, "stop": stop, "join": join, "threads": [] } return f return decorator def lookup(tpe): assert tpe in _TRIGGERS return _TRIGGERS[tpe]["parser"] def start(): for trigger in _TRIGGERS.values(): trigger["threads"].append(trigger["start"]()) def stop(): for trigger in _TRIGGERS.values(): for thread in trigger["threads"]: if thread is not None: trigger["stop"](thread) else: trigger["stop"]() def join(): for trigger in _TRIGGERS.values(): for thread in trigger["threads"]: if thread is not None: trigger["join"](thread) else: trigger["join"]()
bsd-3-clause
axkibe/node-vtk
wrappers/8.1.1/vtkBSplineTransformWrap.cc
14253
/* this file has been autogenerated by vtkNodeJsWrap */ /* editing this might proof futile */ #define VTK_WRAPPING_CXX #define VTK_STREAMS_FWD_ONLY #include <nan.h> #include "vtkWarpTransformWrap.h" #include "vtkBSplineTransformWrap.h" #include "vtkObjectBaseWrap.h" #include "vtkAlgorithmOutputWrap.h" #include "vtkImageDataWrap.h" #include "vtkAbstractTransformWrap.h" #include "../../plus/plus.h" using namespace v8; extern Nan::Persistent<v8::Object> vtkNodeJsNoWrap; Nan::Persistent<v8::FunctionTemplate> VtkBSplineTransformWrap::ptpl; VtkBSplineTransformWrap::VtkBSplineTransformWrap() { } VtkBSplineTransformWrap::VtkBSplineTransformWrap(vtkSmartPointer<vtkBSplineTransform> _native) { native = _native; } VtkBSplineTransformWrap::~VtkBSplineTransformWrap() { } void VtkBSplineTransformWrap::Init(v8::Local<v8::Object> exports) { Nan::SetAccessor(exports, Nan::New("vtkBSplineTransform").ToLocalChecked(), ConstructorGetter); Nan::SetAccessor(exports, Nan::New("BSplineTransform").ToLocalChecked(), ConstructorGetter); } void VtkBSplineTransformWrap::ConstructorGetter( v8::Local<v8::String> property, const Nan::PropertyCallbackInfo<v8::Value>& info) { InitPtpl(); info.GetReturnValue().Set(Nan::New(ptpl)->GetFunction()); } void VtkBSplineTransformWrap::InitPtpl() { if (!ptpl.IsEmpty()) return; v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New); VtkWarpTransformWrap::InitPtpl( ); tpl->Inherit(Nan::New<FunctionTemplate>(VtkWarpTransformWrap::ptpl)); tpl->SetClassName(Nan::New("VtkBSplineTransformWrap").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); Nan::SetPrototypeMethod(tpl, "GetBorderMode", GetBorderMode); Nan::SetPrototypeMethod(tpl, "getBorderMode", GetBorderMode); Nan::SetPrototypeMethod(tpl, "GetBorderModeAsString", GetBorderModeAsString); Nan::SetPrototypeMethod(tpl, "getBorderModeAsString", GetBorderModeAsString); Nan::SetPrototypeMethod(tpl, "GetBorderModeMaxValue", GetBorderModeMaxValue); Nan::SetPrototypeMethod(tpl, "getBorderModeMaxValue", GetBorderModeMaxValue); Nan::SetPrototypeMethod(tpl, "GetBorderModeMinValue", GetBorderModeMinValue); Nan::SetPrototypeMethod(tpl, "getBorderModeMinValue", GetBorderModeMinValue); Nan::SetPrototypeMethod(tpl, "GetCoefficientData", GetCoefficientData); Nan::SetPrototypeMethod(tpl, "getCoefficientData", GetCoefficientData); Nan::SetPrototypeMethod(tpl, "GetDisplacementScale", GetDisplacementScale); Nan::SetPrototypeMethod(tpl, "getDisplacementScale", GetDisplacementScale); Nan::SetPrototypeMethod(tpl, "MakeTransform", MakeTransform); Nan::SetPrototypeMethod(tpl, "makeTransform", MakeTransform); Nan::SetPrototypeMethod(tpl, "NewInstance", NewInstance); Nan::SetPrototypeMethod(tpl, "newInstance", NewInstance); Nan::SetPrototypeMethod(tpl, "SafeDownCast", SafeDownCast); Nan::SetPrototypeMethod(tpl, "safeDownCast", SafeDownCast); Nan::SetPrototypeMethod(tpl, "SetBorderMode", SetBorderMode); Nan::SetPrototypeMethod(tpl, "setBorderMode", SetBorderMode); Nan::SetPrototypeMethod(tpl, "SetBorderModeToEdge", SetBorderModeToEdge); Nan::SetPrototypeMethod(tpl, "setBorderModeToEdge", SetBorderModeToEdge); Nan::SetPrototypeMethod(tpl, "SetBorderModeToZero", SetBorderModeToZero); Nan::SetPrototypeMethod(tpl, "setBorderModeToZero", SetBorderModeToZero); Nan::SetPrototypeMethod(tpl, "SetBorderModeToZeroAtBorder", SetBorderModeToZeroAtBorder); Nan::SetPrototypeMethod(tpl, "setBorderModeToZeroAtBorder", SetBorderModeToZeroAtBorder); Nan::SetPrototypeMethod(tpl, "SetCoefficientConnection", SetCoefficientConnection); Nan::SetPrototypeMethod(tpl, "setCoefficientConnection", SetCoefficientConnection); Nan::SetPrototypeMethod(tpl, "SetCoefficientData", SetCoefficientData); Nan::SetPrototypeMethod(tpl, "setCoefficientData", SetCoefficientData); Nan::SetPrototypeMethod(tpl, "SetDisplacementScale", SetDisplacementScale); Nan::SetPrototypeMethod(tpl, "setDisplacementScale", SetDisplacementScale); #ifdef VTK_NODE_PLUS_VTKBSPLINETRANSFORMWRAP_INITPTPL VTK_NODE_PLUS_VTKBSPLINETRANSFORMWRAP_INITPTPL #endif ptpl.Reset( tpl ); } void VtkBSplineTransformWrap::New(const Nan::FunctionCallbackInfo<v8::Value>& info) { if(!info.IsConstructCall()) { Nan::ThrowError("Constructor not called in a construct call."); return; } if(info.Length() == 0) { vtkSmartPointer<vtkBSplineTransform> native = vtkSmartPointer<vtkBSplineTransform>::New(); VtkBSplineTransformWrap* obj = new VtkBSplineTransformWrap(native); obj->Wrap(info.This()); } else { if(info[0]->ToObject() != vtkNodeJsNoWrap ) { Nan::ThrowError("Parameter Error"); return; } } info.GetReturnValue().Set(info.This()); } void VtkBSplineTransformWrap::GetBorderMode(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetBorderMode(); info.GetReturnValue().Set(Nan::New(r)); } void VtkBSplineTransformWrap::GetBorderModeAsString(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); char const * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetBorderModeAsString(); info.GetReturnValue().Set(Nan::New(r).ToLocalChecked()); } void VtkBSplineTransformWrap::GetBorderModeMaxValue(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetBorderModeMaxValue(); info.GetReturnValue().Set(Nan::New(r)); } void VtkBSplineTransformWrap::GetBorderModeMinValue(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); int r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetBorderModeMinValue(); info.GetReturnValue().Set(Nan::New(r)); } void VtkBSplineTransformWrap::GetCoefficientData(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); vtkImageData * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetCoefficientData(); VtkImageDataWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkImageDataWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkImageDataWrap *w = new VtkImageDataWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkBSplineTransformWrap::GetDisplacementScale(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); double r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->GetDisplacementScale(); info.GetReturnValue().Set(Nan::New(r)); } void VtkBSplineTransformWrap::MakeTransform(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); vtkAbstractTransform * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->MakeTransform(); VtkAbstractTransformWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkAbstractTransformWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkAbstractTransformWrap *w = new VtkAbstractTransformWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkBSplineTransformWrap::NewInstance(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); vtkBSplineTransform * r; if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } r = native->NewInstance(); VtkBSplineTransformWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkBSplineTransformWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkBSplineTransformWrap *w = new VtkBSplineTransformWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); } void VtkBSplineTransformWrap::SafeDownCast(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkObjectBaseWrap::ptpl))->HasInstance(info[0])) { VtkObjectBaseWrap *a0 = ObjectWrap::Unwrap<VtkObjectBaseWrap>(info[0]->ToObject()); vtkBSplineTransform * r; if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } r = native->SafeDownCast( (vtkObjectBase *) a0->native.GetPointer() ); VtkBSplineTransformWrap::InitPtpl(); v8::Local<v8::Value> argv[1] = { Nan::New(vtkNodeJsNoWrap) }; v8::Local<v8::Function> cons = Nan::New<v8::FunctionTemplate>(VtkBSplineTransformWrap::ptpl)->GetFunction(); v8::Local<v8::Object> wo = cons->NewInstance(1, argv); VtkBSplineTransformWrap *w = new VtkBSplineTransformWrap(); w->native = r; w->Wrap(wo); info.GetReturnValue().Set(wo); return; } Nan::ThrowError("Parameter mismatch"); } void VtkBSplineTransformWrap::SetBorderMode(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsInt32()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetBorderMode( info[0]->Int32Value() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkBSplineTransformWrap::SetBorderModeToEdge(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->SetBorderModeToEdge(); } void VtkBSplineTransformWrap::SetBorderModeToZero(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->SetBorderModeToZero(); } void VtkBSplineTransformWrap::SetBorderModeToZeroAtBorder(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); if(info.Length() != 0) { Nan::ThrowError("Too many parameters."); return; } native->SetBorderModeToZeroAtBorder(); } void VtkBSplineTransformWrap::SetCoefficientConnection(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkAlgorithmOutputWrap::ptpl))->HasInstance(info[0])) { VtkAlgorithmOutputWrap *a0 = ObjectWrap::Unwrap<VtkAlgorithmOutputWrap>(info[0]->ToObject()); if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetCoefficientConnection( (vtkAlgorithmOutput *) a0->native.GetPointer() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkBSplineTransformWrap::SetCoefficientData(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsObject() && (Nan::New(VtkImageDataWrap::ptpl))->HasInstance(info[0])) { VtkImageDataWrap *a0 = ObjectWrap::Unwrap<VtkImageDataWrap>(info[0]->ToObject()); if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetCoefficientData( (vtkImageData *) a0->native.GetPointer() ); return; } Nan::ThrowError("Parameter mismatch"); } void VtkBSplineTransformWrap::SetDisplacementScale(const Nan::FunctionCallbackInfo<v8::Value>& info) { VtkBSplineTransformWrap *wrapper = ObjectWrap::Unwrap<VtkBSplineTransformWrap>(info.Holder()); vtkBSplineTransform *native = (vtkBSplineTransform *)wrapper->native.GetPointer(); if(info.Length() > 0 && info[0]->IsNumber()) { if(info.Length() != 1) { Nan::ThrowError("Too many parameters."); return; } native->SetDisplacementScale( info[0]->NumberValue() ); return; } Nan::ThrowError("Parameter mismatch"); }
bsd-3-clause
CoursePark/Zend-Framework-Releases
extras/documentation/api/extras/ZendX_Whois/_Console---Exception.php.html
6115
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- template designed by Marco Von Ballmoos --> <title>Docs for page Exception.php</title> <link rel="stylesheet" href="../media/stylesheet.css" /> <script src="../media/lib/classTree.js"></script> <script language="javascript" type="text/javascript"> var imgPlus = new Image(); var imgMinus = new Image(); imgPlus.src = "../media/images/plus.png"; imgMinus.src = "../media/images/minus.png"; function showNode(Node){ switch(navigator.family){ case 'nn4': // Nav 4.x code fork... var oTable = document.layers["span" + Node]; var oImg = document.layers["img" + Node]; break; case 'ie4': // IE 4/5 code fork... var oTable = document.all["span" + Node]; var oImg = document.all["img" + Node]; break; case 'gecko': // Standards Compliant code fork... var oTable = document.getElementById("span" + Node); var oImg = document.getElementById("img" + Node); break; } oImg.src = imgMinus.src; oTable.style.display = "block"; } function hideNode(Node){ switch(navigator.family){ case 'nn4': // Nav 4.x code fork... var oTable = document.layers["span" + Node]; var oImg = document.layers["img" + Node]; break; case 'ie4': // IE 4/5 code fork... var oTable = document.all["span" + Node]; var oImg = document.all["img" + Node]; break; case 'gecko': // Standards Compliant code fork... var oTable = document.getElementById("span" + Node); var oImg = document.getElementById("img" + Node); break; } oImg.src = imgPlus.src; oTable.style.display = "none"; } function nodeIsVisible(Node){ switch(navigator.family){ case 'nn4': // Nav 4.x code fork... var oTable = document.layers["span" + Node]; break; case 'ie4': // IE 4/5 code fork... var oTable = document.all["span" + Node]; break; case 'gecko': // Standards Compliant code fork... var oTable = document.getElementById("span" + Node); break; } return (oTable && oTable.style.display == "block"); } function toggleNodeVisibility(Node){ if (nodeIsVisible(Node)){ hideNode(Node); }else{ showNode(Node); } } </script> </head> <body> <div class="page-body"> <h2 class="file-name"><img src="../media/images/Page_logo.png" alt="File" style="vertical-align: middle">/Console/Exception.php</h2> <a name="sec-description"></a> <div class="info-box"> <div class="info-box-title">Description</div> <div class="nav-bar"> <span class="disabled">Description</span> | <a href="#sec-classes">Classes</a> | <a href="#sec-includes">Includes</a> </div> <div class="info-box-body"> <!-- ========== Info from phpDoc block ========= --> <p class="short-description">Zend Framework</p> <p class="description"><p>LICENSE</p><p>This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.</p></p> <ul class="tags"> <li><span class="field">version:</span> $Id: Exception.php 20165 2010-01-09 18:57:56Z bkarwin $</li> <li><span class="field">copyright:</span> Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)</li> <li><span class="field">license:</span> <a href="http://framework.zend.com/license/new-bsd">New BSD License</a></li> </ul> </div> </div> <a name="sec-classes"></a> <div class="info-box"> <div class="info-box-title">Classes</div> <div class="nav-bar"> <a href="#sec-description">Description</a> | <span class="disabled">Classes</span> | <a href="#sec-includes">Includes</a> </div> <div class="info-box-body"> <table cellpadding="2" cellspacing="0" class="class-table"> <tr> <th class="class-table-header">Class</th> <th class="class-table-header">Description</th> </tr> <tr> <td style="padding-right: 2em; vertical-align: top; white-space: nowrap"> <img src="../media/images/Class.png" alt=" class" title=" class"/> <a href="../ZendX_Console/ZendX_Console_Exception.html">ZendX_Console_Exception</a> </td> <td> Exception class for ZendX_Console </td> </tr> </table> </div> </div> <a name="sec-includes"></a> <div class="info-box"> <div class="info-box-title">Includes</div> <div class="nav-bar"> <a href="#sec-description">Description</a> | <a href="#sec-classes">Classes</a> | <span class="disabled">Includes</span> </div> <div class="info-box-body"> <a name="_ZendX/Exception_php"><!-- --></a> <div class="evenrow"> <div> <img src="../media/images/Page.png" alt=" " /> <span class="include-title"> <span class="include-type">require_once</span> (<span class="include-name">'ZendX/Exception.php'</span>) (line <span class="line-number">25</span>) </span> </div> <!-- ========== Info from phpDoc block ========= --> <ul class="tags"> <li><span class="field">see:</span> <a href="../ZendX/ZendX_Exception.html">ZendX_Exception</a></li> </ul> </div> </div> </div> <p class="notes" id="credit"> Documentation generated on Wed, 02 Mar 2011 14:24:18 -0500 by <a href="http://www.phpdoc.org" target="_blank">phpDocumentor 1.4.3</a> </p> </div></body> </html>
bsd-3-clause
chaoling/test123
linux-2.6.39/drivers/net/smsc911x.h
12608
/*************************************************************************** * * Copyright (C) 2004-2008 SMSC * Copyright (C) 2005-2008 ARM * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef __SMSC911X_H__ #define __SMSC911X_H__ #define TX_FIFO_LOW_THRESHOLD ((u32)1600) #define SMSC911X_EEPROM_SIZE ((u32)128) #define USE_DEBUG 0 /* This is the maximum number of packets to be received every * NAPI poll */ #define SMSC_NAPI_WEIGHT 16 /* implements a PHY loopback test at initialisation time, to ensure a packet * can be successfully looped back */ #define USE_PHY_WORK_AROUND #define DPRINTK(nlevel, klevel, fmt, args...) \ ((void)((NETIF_MSG_##nlevel & pdata->msg_enable) && \ printk(KERN_##klevel "%s: %s: " fmt "\n", \ pdata->dev->name, __func__, ## args))) #if USE_DEBUG >= 1 #define SMSC_WARNING(nlevel, fmt, args...) \ DPRINTK(nlevel, WARNING, fmt, ## args) #else #define SMSC_WARNING(nlevel, fmt, args...) \ ({ do {} while (0); 0; }) #endif #if USE_DEBUG >= 2 #define SMSC_TRACE(nlevel, fmt, args...) \ DPRINTK(nlevel, INFO, fmt, ## args) #else #define SMSC_TRACE(nlevel, fmt, args...) \ ({ do {} while (0); 0; }) #endif #ifdef CONFIG_DEBUG_SPINLOCK #define SMSC_ASSERT_MAC_LOCK(pdata) \ WARN_ON(!spin_is_locked(&pdata->mac_lock)) #else #define SMSC_ASSERT_MAC_LOCK(pdata) do {} while (0) #endif /* CONFIG_DEBUG_SPINLOCK */ /* SMSC911x registers and bitfields */ #define RX_DATA_FIFO 0x00 #define TX_DATA_FIFO 0x20 #define TX_CMD_A_ON_COMP_ 0x80000000 #define TX_CMD_A_BUF_END_ALGN_ 0x03000000 #define TX_CMD_A_4_BYTE_ALGN_ 0x00000000 #define TX_CMD_A_16_BYTE_ALGN_ 0x01000000 #define TX_CMD_A_32_BYTE_ALGN_ 0x02000000 #define TX_CMD_A_DATA_OFFSET_ 0x001F0000 #define TX_CMD_A_FIRST_SEG_ 0x00002000 #define TX_CMD_A_LAST_SEG_ 0x00001000 #define TX_CMD_A_BUF_SIZE_ 0x000007FF #define TX_CMD_B_PKT_TAG_ 0xFFFF0000 #define TX_CMD_B_ADD_CRC_DISABLE_ 0x00002000 #define TX_CMD_B_DISABLE_PADDING_ 0x00001000 #define TX_CMD_B_PKT_BYTE_LENGTH_ 0x000007FF #define RX_STATUS_FIFO 0x40 #define RX_STS_ES_ 0x00008000 #define RX_STS_LENGTH_ERR_ 0x00001000 #define RX_STS_MCAST_ 0x00000400 #define RX_STS_FRAME_TYPE_ 0x00000020 #define RX_STS_CRC_ERR_ 0x00000002 #define RX_STATUS_FIFO_PEEK 0x44 #define TX_STATUS_FIFO 0x48 #define TX_STS_ES_ 0x00008000 #define TX_STS_LOST_CARRIER_ 0x00000800 #define TX_STS_NO_CARRIER_ 0x00000400 #define TX_STS_LATE_COL_ 0x00000200 #define TX_STS_EXCESS_COL_ 0x00000100 #define TX_STATUS_FIFO_PEEK 0x4C #define ID_REV 0x50 #define ID_REV_CHIP_ID_ 0xFFFF0000 #define ID_REV_REV_ID_ 0x0000FFFF #define INT_CFG 0x54 #define INT_CFG_INT_DEAS_ 0xFF000000 #define INT_CFG_INT_DEAS_CLR_ 0x00004000 #define INT_CFG_INT_DEAS_STS_ 0x00002000 #define INT_CFG_IRQ_INT_ 0x00001000 #define INT_CFG_IRQ_EN_ 0x00000100 #define INT_CFG_IRQ_POL_ 0x00000010 #define INT_CFG_IRQ_TYPE_ 0x00000001 #define INT_STS 0x58 #define INT_STS_SW_INT_ 0x80000000 #define INT_STS_TXSTOP_INT_ 0x02000000 #define INT_STS_RXSTOP_INT_ 0x01000000 #define INT_STS_RXDFH_INT_ 0x00800000 #define INT_STS_RXDF_INT_ 0x00400000 #define INT_STS_TX_IOC_ 0x00200000 #define INT_STS_RXD_INT_ 0x00100000 #define INT_STS_GPT_INT_ 0x00080000 #define INT_STS_PHY_INT_ 0x00040000 #define INT_STS_PME_INT_ 0x00020000 #define INT_STS_TXSO_ 0x00010000 #define INT_STS_RWT_ 0x00008000 #define INT_STS_RXE_ 0x00004000 #define INT_STS_TXE_ 0x00002000 #define INT_STS_TDFU_ 0x00000800 #define INT_STS_TDFO_ 0x00000400 #define INT_STS_TDFA_ 0x00000200 #define INT_STS_TSFF_ 0x00000100 #define INT_STS_TSFL_ 0x00000080 #define INT_STS_RXDF_ 0x00000040 #define INT_STS_RDFL_ 0x00000020 #define INT_STS_RSFF_ 0x00000010 #define INT_STS_RSFL_ 0x00000008 #define INT_STS_GPIO2_INT_ 0x00000004 #define INT_STS_GPIO1_INT_ 0x00000002 #define INT_STS_GPIO0_INT_ 0x00000001 #define INT_EN 0x5C #define INT_EN_SW_INT_EN_ 0x80000000 #define INT_EN_TXSTOP_INT_EN_ 0x02000000 #define INT_EN_RXSTOP_INT_EN_ 0x01000000 #define INT_EN_RXDFH_INT_EN_ 0x00800000 #define INT_EN_TIOC_INT_EN_ 0x00200000 #define INT_EN_RXD_INT_EN_ 0x00100000 #define INT_EN_GPT_INT_EN_ 0x00080000 #define INT_EN_PHY_INT_EN_ 0x00040000 #define INT_EN_PME_INT_EN_ 0x00020000 #define INT_EN_TXSO_EN_ 0x00010000 #define INT_EN_RWT_EN_ 0x00008000 #define INT_EN_RXE_EN_ 0x00004000 #define INT_EN_TXE_EN_ 0x00002000 #define INT_EN_TDFU_EN_ 0x00000800 #define INT_EN_TDFO_EN_ 0x00000400 #define INT_EN_TDFA_EN_ 0x00000200 #define INT_EN_TSFF_EN_ 0x00000100 #define INT_EN_TSFL_EN_ 0x00000080 #define INT_EN_RXDF_EN_ 0x00000040 #define INT_EN_RDFL_EN_ 0x00000020 #define INT_EN_RSFF_EN_ 0x00000010 #define INT_EN_RSFL_EN_ 0x00000008 #define INT_EN_GPIO2_INT_ 0x00000004 #define INT_EN_GPIO1_INT_ 0x00000002 #define INT_EN_GPIO0_INT_ 0x00000001 #define BYTE_TEST 0x64 #define FIFO_INT 0x68 #define FIFO_INT_TX_AVAIL_LEVEL_ 0xFF000000 #define FIFO_INT_TX_STS_LEVEL_ 0x00FF0000 #define FIFO_INT_RX_AVAIL_LEVEL_ 0x0000FF00 #define FIFO_INT_RX_STS_LEVEL_ 0x000000FF #define RX_CFG 0x6C #define RX_CFG_RX_END_ALGN_ 0xC0000000 #define RX_CFG_RX_END_ALGN4_ 0x00000000 #define RX_CFG_RX_END_ALGN16_ 0x40000000 #define RX_CFG_RX_END_ALGN32_ 0x80000000 #define RX_CFG_RX_DMA_CNT_ 0x0FFF0000 #define RX_CFG_RX_DUMP_ 0x00008000 #define RX_CFG_RXDOFF_ 0x00001F00 #define TX_CFG 0x70 #define TX_CFG_TXS_DUMP_ 0x00008000 #define TX_CFG_TXD_DUMP_ 0x00004000 #define TX_CFG_TXSAO_ 0x00000004 #define TX_CFG_TX_ON_ 0x00000002 #define TX_CFG_STOP_TX_ 0x00000001 #define HW_CFG 0x74 #define HW_CFG_TTM_ 0x00200000 #define HW_CFG_SF_ 0x00100000 #define HW_CFG_TX_FIF_SZ_ 0x000F0000 #define HW_CFG_TR_ 0x00003000 #define HW_CFG_SRST_ 0x00000001 /* only available on 115/117 */ #define HW_CFG_PHY_CLK_SEL_ 0x00000060 #define HW_CFG_PHY_CLK_SEL_INT_PHY_ 0x00000000 #define HW_CFG_PHY_CLK_SEL_EXT_PHY_ 0x00000020 #define HW_CFG_PHY_CLK_SEL_CLK_DIS_ 0x00000040 #define HW_CFG_SMI_SEL_ 0x00000010 #define HW_CFG_EXT_PHY_DET_ 0x00000008 #define HW_CFG_EXT_PHY_EN_ 0x00000004 #define HW_CFG_SRST_TO_ 0x00000002 /* only available on 116/118 */ #define HW_CFG_32_16_BIT_MODE_ 0x00000004 #define RX_DP_CTRL 0x78 #define RX_DP_CTRL_RX_FFWD_ 0x80000000 #define RX_FIFO_INF 0x7C #define RX_FIFO_INF_RXSUSED_ 0x00FF0000 #define RX_FIFO_INF_RXDUSED_ 0x0000FFFF #define TX_FIFO_INF 0x80 #define TX_FIFO_INF_TSUSED_ 0x00FF0000 #define TX_FIFO_INF_TDFREE_ 0x0000FFFF #define PMT_CTRL 0x84 #define PMT_CTRL_PM_MODE_ 0x00003000 #define PMT_CTRL_PM_MODE_D0_ 0x00000000 #define PMT_CTRL_PM_MODE_D1_ 0x00001000 #define PMT_CTRL_PM_MODE_D2_ 0x00002000 #define PMT_CTRL_PM_MODE_D3_ 0x00003000 #define PMT_CTRL_PHY_RST_ 0x00000400 #define PMT_CTRL_WOL_EN_ 0x00000200 #define PMT_CTRL_ED_EN_ 0x00000100 #define PMT_CTRL_PME_TYPE_ 0x00000040 #define PMT_CTRL_WUPS_ 0x00000030 #define PMT_CTRL_WUPS_NOWAKE_ 0x00000000 #define PMT_CTRL_WUPS_ED_ 0x00000010 #define PMT_CTRL_WUPS_WOL_ 0x00000020 #define PMT_CTRL_WUPS_MULTI_ 0x00000030 #define PMT_CTRL_PME_IND_ 0x00000008 #define PMT_CTRL_PME_POL_ 0x00000004 #define PMT_CTRL_PME_EN_ 0x00000002 #define PMT_CTRL_READY_ 0x00000001 #define GPIO_CFG 0x88 #define GPIO_CFG_LED3_EN_ 0x40000000 #define GPIO_CFG_LED2_EN_ 0x20000000 #define GPIO_CFG_LED1_EN_ 0x10000000 #define GPIO_CFG_GPIO2_INT_POL_ 0x04000000 #define GPIO_CFG_GPIO1_INT_POL_ 0x02000000 #define GPIO_CFG_GPIO0_INT_POL_ 0x01000000 #define GPIO_CFG_EEPR_EN_ 0x00700000 #define GPIO_CFG_GPIOBUF2_ 0x00040000 #define GPIO_CFG_GPIOBUF1_ 0x00020000 #define GPIO_CFG_GPIOBUF0_ 0x00010000 #define GPIO_CFG_GPIODIR2_ 0x00000400 #define GPIO_CFG_GPIODIR1_ 0x00000200 #define GPIO_CFG_GPIODIR0_ 0x00000100 #define GPIO_CFG_GPIOD4_ 0x00000020 #define GPIO_CFG_GPIOD3_ 0x00000010 #define GPIO_CFG_GPIOD2_ 0x00000004 #define GPIO_CFG_GPIOD1_ 0x00000002 #define GPIO_CFG_GPIOD0_ 0x00000001 #define GPT_CFG 0x8C #define GPT_CFG_TIMER_EN_ 0x20000000 #define GPT_CFG_GPT_LOAD_ 0x0000FFFF #define GPT_CNT 0x90 #define GPT_CNT_GPT_CNT_ 0x0000FFFF #define WORD_SWAP 0x98 #define FREE_RUN 0x9C #define RX_DROP 0xA0 #define MAC_CSR_CMD 0xA4 #define MAC_CSR_CMD_CSR_BUSY_ 0x80000000 #define MAC_CSR_CMD_R_NOT_W_ 0x40000000 #define MAC_CSR_CMD_CSR_ADDR_ 0x000000FF #define MAC_CSR_DATA 0xA8 #define AFC_CFG 0xAC #define AFC_CFG_AFC_HI_ 0x00FF0000 #define AFC_CFG_AFC_LO_ 0x0000FF00 #define AFC_CFG_BACK_DUR_ 0x000000F0 #define AFC_CFG_FCMULT_ 0x00000008 #define AFC_CFG_FCBRD_ 0x00000004 #define AFC_CFG_FCADD_ 0x00000002 #define AFC_CFG_FCANY_ 0x00000001 #define E2P_CMD 0xB0 #define E2P_CMD_EPC_BUSY_ 0x80000000 #define E2P_CMD_EPC_CMD_ 0x70000000 #define E2P_CMD_EPC_CMD_READ_ 0x00000000 #define E2P_CMD_EPC_CMD_EWDS_ 0x10000000 #define E2P_CMD_EPC_CMD_EWEN_ 0x20000000 #define E2P_CMD_EPC_CMD_WRITE_ 0x30000000 #define E2P_CMD_EPC_CMD_WRAL_ 0x40000000 #define E2P_CMD_EPC_CMD_ERASE_ 0x50000000 #define E2P_CMD_EPC_CMD_ERAL_ 0x60000000 #define E2P_CMD_EPC_CMD_RELOAD_ 0x70000000 #define E2P_CMD_EPC_TIMEOUT_ 0x00000200 #define E2P_CMD_MAC_ADDR_LOADED_ 0x00000100 #define E2P_CMD_EPC_ADDR_ 0x000000FF #define E2P_DATA 0xB4 #define E2P_DATA_EEPROM_DATA_ 0x000000FF #define LAN_REGISTER_EXTENT 0x00000100 /* * MAC Control and Status Register (Indirect Address) * Offset (through the MAC_CSR CMD and DATA port) */ #define MAC_CR 0x01 #define MAC_CR_RXALL_ 0x80000000 #define MAC_CR_HBDIS_ 0x10000000 #define MAC_CR_RCVOWN_ 0x00800000 #define MAC_CR_LOOPBK_ 0x00200000 #define MAC_CR_FDPX_ 0x00100000 #define MAC_CR_MCPAS_ 0x00080000 #define MAC_CR_PRMS_ 0x00040000 #define MAC_CR_INVFILT_ 0x00020000 #define MAC_CR_PASSBAD_ 0x00010000 #define MAC_CR_HFILT_ 0x00008000 #define MAC_CR_HPFILT_ 0x00002000 #define MAC_CR_LCOLL_ 0x00001000 #define MAC_CR_BCAST_ 0x00000800 #define MAC_CR_DISRTY_ 0x00000400 #define MAC_CR_PADSTR_ 0x00000100 #define MAC_CR_BOLMT_MASK_ 0x000000C0 #define MAC_CR_DFCHK_ 0x00000020 #define MAC_CR_TXEN_ 0x00000008 #define MAC_CR_RXEN_ 0x00000004 #define ADDRH 0x02 #define ADDRL 0x03 #define HASHH 0x04 #define HASHL 0x05 #define MII_ACC 0x06 #define MII_ACC_PHY_ADDR_ 0x0000F800 #define MII_ACC_MIIRINDA_ 0x000007C0 #define MII_ACC_MII_WRITE_ 0x00000002 #define MII_ACC_MII_BUSY_ 0x00000001 #define MII_DATA 0x07 #define FLOW 0x08 #define FLOW_FCPT_ 0xFFFF0000 #define FLOW_FCPASS_ 0x00000004 #define FLOW_FCEN_ 0x00000002 #define FLOW_FCBSY_ 0x00000001 #define VLAN1 0x09 #define VLAN2 0x0A #define WUFF 0x0B #define WUCSR 0x0C #define WUCSR_GUE_ 0x00000200 #define WUCSR_WUFR_ 0x00000040 #define WUCSR_MPR_ 0x00000020 #define WUCSR_WAKE_EN_ 0x00000004 #define WUCSR_MPEN_ 0x00000002 /* * Phy definitions (vendor-specific) */ #define LAN9118_PHY_ID 0x00C0001C #define MII_INTSTS 0x1D #define MII_INTMSK 0x1E #define PHY_INTMSK_AN_RCV_ (1 << 1) #define PHY_INTMSK_PDFAULT_ (1 << 2) #define PHY_INTMSK_AN_ACK_ (1 << 3) #define PHY_INTMSK_LNKDOWN_ (1 << 4) #define PHY_INTMSK_RFAULT_ (1 << 5) #define PHY_INTMSK_AN_COMP_ (1 << 6) #define PHY_INTMSK_ENERGYON_ (1 << 7) #define PHY_INTMSK_DEFAULT_ (PHY_INTMSK_ENERGYON_ | \ PHY_INTMSK_AN_COMP_ | \ PHY_INTMSK_RFAULT_ | \ PHY_INTMSK_LNKDOWN_) #define ADVERTISE_PAUSE_ALL (ADVERTISE_PAUSE_CAP | \ ADVERTISE_PAUSE_ASYM) #define LPA_PAUSE_ALL (LPA_PAUSE_CAP | \ LPA_PAUSE_ASYM) /* * Provide hooks to let the arch add to the initialisation procedure * and to override the source of the MAC address. */ #define SMSC_INITIALIZE() do {} while (0) #define smsc_get_mac(dev) smsc911x_read_mac_address((dev)) #ifdef CONFIG_SMSC911X_ARCH_HOOKS #include <asm/smsc911x.h> #endif #endif /* __SMSC911X_H__ */
gpl-2.0
AiJiaZone/linux-4.0
virt/drivers/ide/ht6560b.c
10680
/* * Copyright (C) 1995-2000 Linus Torvalds & author (see below) */ /* * HT-6560B EIDE-controller support * To activate controller support use kernel parameter "ide0=ht6560b". * Use hdparm utility to enable PIO mode support. * * Author: Mikko Ala-Fossi <[email protected]> * Jan Evert van Grootheest <[email protected]> * */ #define DRV_NAME "ht6560b" #define HT6560B_VERSION "v0.08" #include <linux/module.h> #include <linux/types.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/timer.h> #include <linux/mm.h> #include <linux/ioport.h> #include <linux/blkdev.h> #include <linux/ide.h> #include <linux/init.h> #include <asm/io.h> /* #define DEBUG */ /* remove comments for DEBUG messages */ /* * The special i/o-port that HT-6560B uses to configuration: * bit0 (0x01): "1" selects secondary interface * bit2 (0x04): "1" enables FIFO function * bit5 (0x20): "1" enables prefetched data read function (???) * * The special i/o-port that HT-6560A uses to configuration: * bit0 (0x01): "1" selects secondary interface * bit1 (0x02): "1" enables prefetched data read function * bit2 (0x04): "0" enables multi-master system (?) * bit3 (0x08): "1" 3 cycle time, "0" 2 cycle time (?) */ #define HT_CONFIG_PORT 0x3e6 static inline u8 HT_CONFIG(ide_drive_t *drive) { return ((unsigned long)ide_get_drivedata(drive) & 0xff00) >> 8; } /* * FIFO + PREFETCH (both a/b-model) */ #define HT_CONFIG_DEFAULT 0x1c /* no prefetch */ /* #define HT_CONFIG_DEFAULT 0x3c */ /* with prefetch */ #define HT_SECONDARY_IF 0x01 #define HT_PREFETCH_MODE 0x20 /* * ht6560b Timing values: * * I reviewed some assembler source listings of htide drivers and found * out how they setup those cycle time interfacing values, as they at Holtek * call them. IDESETUP.COM that is supplied with the drivers figures out * optimal values and fetches those values to drivers. I found out that * they use Select register to fetch timings to the ide board right after * interface switching. After that it was quite easy to add code to * ht6560b.c. * * IDESETUP.COM gave me values 0x24, 0x45, 0xaa, 0xff that worked fine * for hda and hdc. But hdb needed higher values to work, so I guess * that sometimes it is necessary to give higher value than IDESETUP * gives. [see cmd640.c for an extreme example of this. -ml] * * Perhaps I should explain something about these timing values: * The higher nibble of value is the Recovery Time (rt) and the lower nibble * of the value is the Active Time (at). Minimum value 2 is the fastest and * the maximum value 15 is the slowest. Default values should be 15 for both. * So 0x24 means 2 for rt and 4 for at. Each of the drives should have * both values, and IDESETUP gives automatically rt=15 st=15 for CDROMs or * similar. If value is too small there will be all sorts of failures. * * Timing byte consists of * High nibble: Recovery Cycle Time (rt) * The valid values range from 2 to 15. The default is 15. * * Low nibble: Active Cycle Time (at) * The valid values range from 2 to 15. The default is 15. * * You can obtain optimized timing values by running Holtek IDESETUP.COM * for DOS. DOS drivers get their timing values from command line, where * the first value is the Recovery Time and the second value is the * Active Time for each drive. Smaller value gives higher speed. * In case of failures you should probably fall back to a higher value. */ static inline u8 HT_TIMING(ide_drive_t *drive) { return (unsigned long)ide_get_drivedata(drive) & 0x00ff; } #define HT_TIMING_DEFAULT 0xff /* * This routine handles interface switching for the peculiar hardware design * on the F.G.I./Holtek HT-6560B VLB IDE interface. * The HT-6560B can only enable one IDE port at a time, and requires a * silly sequence (below) whenever we switch between primary and secondary. */ /* * This routine is invoked from ide.c to prepare for access to a given drive. */ static void ht6560b_dev_select(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; unsigned long flags; static u8 current_select = 0; static u8 current_timing = 0; u8 select, timing; local_irq_save(flags); select = HT_CONFIG(drive); timing = HT_TIMING(drive); /* * Need to enforce prefetch sometimes because otherwise * it'll hang (hard). */ if (drive->media != ide_disk || (drive->dev_flags & IDE_DFLAG_PRESENT) == 0) select |= HT_PREFETCH_MODE; if (select != current_select || timing != current_timing) { current_select = select; current_timing = timing; (void)inb(HT_CONFIG_PORT); (void)inb(HT_CONFIG_PORT); (void)inb(HT_CONFIG_PORT); (void)inb(HT_CONFIG_PORT); outb(select, HT_CONFIG_PORT); /* * Set timing for this drive: */ outb(timing, hwif->io_ports.device_addr); (void)inb(hwif->io_ports.status_addr); #ifdef DEBUG printk("ht6560b: %s: select=%#x timing=%#x\n", drive->name, select, timing); #endif } local_irq_restore(flags); outb(drive->select | ATA_DEVICE_OBS, hwif->io_ports.device_addr); } /* * Autodetection and initialization of ht6560b */ static int __init try_to_init_ht6560b(void) { u8 orig_value; int i; /* Autodetect ht6560b */ if ((orig_value = inb(HT_CONFIG_PORT)) == 0xff) return 0; for (i=3;i>0;i--) { outb(0x00, HT_CONFIG_PORT); if (!( (~inb(HT_CONFIG_PORT)) & 0x3f )) { outb(orig_value, HT_CONFIG_PORT); return 0; } } outb(0x00, HT_CONFIG_PORT); if ((~inb(HT_CONFIG_PORT))& 0x3f) { outb(orig_value, HT_CONFIG_PORT); return 0; } /* * Ht6560b autodetected */ outb(HT_CONFIG_DEFAULT, HT_CONFIG_PORT); outb(HT_TIMING_DEFAULT, 0x1f6); /* Select register */ (void)inb(0x1f7); /* Status register */ printk("ht6560b " HT6560B_VERSION ": chipset detected and initialized" #ifdef DEBUG " with debug enabled" #endif "\n" ); return 1; } static u8 ht_pio2timings(ide_drive_t *drive, const u8 pio) { int active_time, recovery_time; int active_cycles, recovery_cycles; int bus_speed = ide_vlb_clk ? ide_vlb_clk : 50; if (pio) { unsigned int cycle_time; struct ide_timing *t = ide_timing_find_mode(XFER_PIO_0 + pio); cycle_time = ide_pio_cycle_time(drive, pio); /* * Just like opti621.c we try to calculate the * actual cycle time for recovery and activity * according system bus speed. */ active_time = t->active; recovery_time = cycle_time - active_time - t->setup; /* * Cycle times should be Vesa bus cycles */ active_cycles = (active_time * bus_speed + 999) / 1000; recovery_cycles = (recovery_time * bus_speed + 999) / 1000; /* * Upper and lower limits */ if (active_cycles < 2) active_cycles = 2; if (recovery_cycles < 2) recovery_cycles = 2; if (active_cycles > 15) active_cycles = 15; if (recovery_cycles > 15) recovery_cycles = 0; /* 0==16 */ #ifdef DEBUG printk("ht6560b: drive %s setting pio=%d recovery=%d (%dns) active=%d (%dns)\n", drive->name, pio, recovery_cycles, recovery_time, active_cycles, active_time); #endif return (u8)((recovery_cycles << 4) | active_cycles); } else { #ifdef DEBUG printk("ht6560b: drive %s setting pio=0\n", drive->name); #endif return HT_TIMING_DEFAULT; /* default setting */ } } static DEFINE_SPINLOCK(ht6560b_lock); /* * Enable/Disable so called prefetch mode */ static void ht_set_prefetch(ide_drive_t *drive, u8 state) { unsigned long flags, config; int t = HT_PREFETCH_MODE << 8; spin_lock_irqsave(&ht6560b_lock, flags); config = (unsigned long)ide_get_drivedata(drive); /* * Prefetch mode and unmask irq seems to conflict */ if (state) { config |= t; /* enable prefetch mode */ drive->dev_flags |= IDE_DFLAG_NO_UNMASK; drive->dev_flags &= ~IDE_DFLAG_UNMASK; } else { config &= ~t; /* disable prefetch mode */ drive->dev_flags &= ~IDE_DFLAG_NO_UNMASK; } ide_set_drivedata(drive, (void *)config); spin_unlock_irqrestore(&ht6560b_lock, flags); #ifdef DEBUG printk("ht6560b: drive %s prefetch mode %sabled\n", drive->name, (state ? "en" : "dis")); #endif } static void ht6560b_set_pio_mode(ide_hwif_t *hwif, ide_drive_t *drive) { unsigned long flags, config; const u8 pio = drive->pio_mode - XFER_PIO_0; u8 timing; switch (pio) { case 8: /* set prefetch off */ case 9: /* set prefetch on */ ht_set_prefetch(drive, pio & 1); return; } timing = ht_pio2timings(drive, pio); spin_lock_irqsave(&ht6560b_lock, flags); config = (unsigned long)ide_get_drivedata(drive); config &= 0xff00; config |= timing; ide_set_drivedata(drive, (void *)config); spin_unlock_irqrestore(&ht6560b_lock, flags); #ifdef DEBUG printk("ht6560b: drive %s tuned to pio mode %#x timing=%#x\n", drive->name, pio, timing); #endif } static void __init ht6560b_init_dev(ide_drive_t *drive) { ide_hwif_t *hwif = drive->hwif; /* Setting default configurations for drives. */ int t = (HT_CONFIG_DEFAULT << 8) | HT_TIMING_DEFAULT; if (hwif->channel) t |= (HT_SECONDARY_IF << 8); ide_set_drivedata(drive, (void *)t); } static bool probe_ht6560b; module_param_named(probe, probe_ht6560b, bool, 0); MODULE_PARM_DESC(probe, "probe for HT6560B chipset"); static const struct ide_tp_ops ht6560b_tp_ops = { .exec_command = ide_exec_command, .read_status = ide_read_status, .read_altstatus = ide_read_altstatus, .write_devctl = ide_write_devctl, .dev_select = ht6560b_dev_select, .tf_load = ide_tf_load, .tf_read = ide_tf_read, .input_data = ide_input_data, .output_data = ide_output_data, }; static const struct ide_port_ops ht6560b_port_ops = { .init_dev = ht6560b_init_dev, .set_pio_mode = ht6560b_set_pio_mode, }; static const struct ide_port_info ht6560b_port_info __initconst = { .name = DRV_NAME, .chipset = ide_ht6560b, .tp_ops = &ht6560b_tp_ops, .port_ops = &ht6560b_port_ops, .host_flags = IDE_HFLAG_SERIALIZE | /* is this needed? */ IDE_HFLAG_NO_DMA | IDE_HFLAG_ABUSE_PREFETCH, .pio_mask = ATA_PIO4, }; static int __init ht6560b_init(void) { if (probe_ht6560b == 0) return -ENODEV; if (!request_region(HT_CONFIG_PORT, 1, DRV_NAME)) { printk(KERN_NOTICE "%s: HT_CONFIG_PORT not found\n", __func__); return -ENODEV; } if (!try_to_init_ht6560b()) { printk(KERN_NOTICE "%s: HBA not found\n", __func__); goto release_region; } return ide_legacy_device_add(&ht6560b_port_info, 0); release_region: release_region(HT_CONFIG_PORT, 1); return -ENODEV; } module_init(ht6560b_init); MODULE_AUTHOR("See Local File"); MODULE_DESCRIPTION("HT-6560B EIDE-controller support"); MODULE_LICENSE("GPL");
gpl-2.0
pscedu/slash2-stable
pfl/tests/multiwait/Makefile
146
# $Id$ ROOTDIR=../../.. include ${ROOTDIR}/Makefile.path TEST= multiwait_test SRCS+= multiwait_test.c MODULES+= pthread pfl include ${PFLMK}
isc
SymbiFlow/nextpnr
machxo2/README.md
3054
# `nextpnr-machxo2` _Experimental_ FOSS Place And Route backend for the Lattice MachXO2 family of FPGAs. Fuzzing takes place as a subproject of [`prjtrellis`](https://github.com/YosysHQ/prjtrellis). Known to work: * Basic routing from pads to SLICEs and back! * Basic packing of one type of FF and LUT into _half_ of a SLICE! * Using the internal oscillator `OSCH` as a clock * `LOGIC` SLICE mode Things that probably work but are untested: * Any non-3.3V I/O standard that doesn't use bank VREFs. Things remaining to do include (but not limited to): * More intelligent and efficient packing * Global Routing (exists in database/sim models, `nextpnr-machxo2` doesn't use it yet) * Secondary High Fanout Nets * Edge Clocks (clock pads work, but not routed to global routing yet) * PLLs * Synchronous Release Global Set/Reset Interface (`SGSR`) * Embedded Function Block (`EFB`) * All DDR-related functionality * Bank VREFs * Embedded Block RAM (`EBR`) * `CCU2` and `DPRAM` SLICE modes ## Quick Start The following commands are known to work on a near-fresh Linux Mint system (thank you [securelyfitz](https://twitter.com/securelyfitz)!): ### Prerequisites ``` sudo apt install cmake clang-format libboost-all-dev build-essential qt5-default libeigen3-dev build-essential clang bison flex libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot pkg-config python3 libboost-system-dev libboost-python-dev libboost-filesystem-dev zlib1g-dev python3-setuptools python3-serial ``` ### Installation Use an empty directory to hold all the cloned repositories. Upstream repos can be used as well (e.g. [`YosysHQ/prjtrellis`](https://github.com/YosysHQ/prjtrellis), etc.). ``` git clone [email protected]:cr1901/prjtrellis.git cd prjtrellis git checkout facade git submodule update --init --recursive cd libtrellis cmake -DCMAKE_INSTALL_PREFIX=/usr make -j 8 sudo make install cd ../../ git clone [email protected]:cr1901/yosys.git cd yosys/ git checkout machxo2 make config-gcc make sudo make install cd ../ git clone [email protected]:tinyfpga/TinyFPGA-A-Programmer.git cd TinyFPGA-A-Programmer/ sudo python setup.py install cd ../ git clone [email protected]:cr1901/nextpnr.git cd nextpnr git checkout machxo2 git submodule update --init --recursive cmake . -DARCH=machxo2 -DBUILD_GUI=OFF -DTRELLIS_INSTALL_PREFIX=/usr -DBUILD_PYTHON=OFF -DBUILD_HEAP=OFF make ``` Although uncommon, the `facade` and `machxo2` branches of the above repos are occassionally rebased; use `git pull -f` if necessary. ### Demo If you have a [TinyFPGA Ax2](https://store.tinyfpga.com/products/tinyfpga-a2) board with the [TinyFPGA Programmer](https://store.tinyfpga.com/products/tinyfpga-programmer), the following script will build a blinky bitstream and load it onto the MachXO2; the gateware will flash the LED! ``` cd machxo2/examples/ sh demo.sh tinyfpga ``` The `tinyfpga.v` code used in `demo.sh` is slightly modified from the [user's guide](https://tinyfpga.com/a-series-guide.html) to accommodate `(* LOC = "pin" *)` constraints and the built-in user LED.
isc
TigerBSD/TigerBSD
FreeBSD/sys/boot/powerpc/boot1.chrp/Makefile
1002
# $FreeBSD$ SSP_CFLAGS= PROG= boot1.elf NEWVERSWHAT= "Open Firmware boot block" ${MACHINE_ARCH} BINDIR?= /boot INSTALLFLAGS= -b FILES= boot1.hfs SRCS= boot1.c ashldi3.c syncicache.c MAN= CFLAGS= -ffreestanding -msoft-float \ -I${.CURDIR}/../../common -I${.CURDIR}/../../../ \ -D_STANDALONE LDFLAGS=-nostdlib -static -Wl,-N .include "${.CURDIR}/../Makefile.inc" .PATH: ${.CURDIR}/../../../libkern ${.CURDIR}/../../../../lib/libc/powerpc/gen ${.CURDIR} # The following inserts out objects into a template HFS # created by generate-hfs.sh .include "${.CURDIR}/Makefile.hfs" boot1.hfs: boot1.elf bootinfo.txt echo ${.OBJDIR} uudecode ${.CURDIR}/hfs.tmpl.bz2.uu mv hfs.tmpl.bz2 ${.TARGET}.bz2 bzip2 -f -d ${.TARGET}.bz2 dd if=boot1.elf of=${.TARGET} seek=${BOOT1_OFFSET} conv=notrunc dd if=${.CURDIR}/bootinfo.txt of=${.TARGET} seek=${BOOTINFO_OFFSET} \ conv=notrunc CLEANFILES= boot1.hfs boot1.o: ${.CURDIR}/../../common/ufsread.c .include <bsd.prog.mk>
isc
sstur/draft-js-export-html
packages/draft-js-export-html/typings/index.d.ts
833
/// <reference types="draft-js" /> declare module 'draft-js-export-html' { import draftjs = require("draft-js"); type BlockStyleFn = (block: draftjs.ContentBlock) => RenderConfig|undefined; type EntityStyleFn = (entity: draftjs.EntityInstance) => RenderConfig|undefined; type BlockRenderer = (block: draftjs.ContentBlock) => string; type RenderConfig = { element?: string; attributes?: any; style?: any; }; export interface Options { defaultBlockTag?: string | null; inlineStyles?: { [styleName: string]: RenderConfig }; blockRenderers?: { [blockType: string]: BlockRenderer }; blockStyleFn?: BlockStyleFn; entityStyleFn?: EntityStyleFn; } export function stateToHTML(content: draftjs.ContentState, options?: Options): string; }
isc
TigerBSD/TigerBSD
FreeBSD/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
46056
/*- * Copyright (c) 2012 Chelsio Communications, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); #include "opt_inet.h" #ifdef TCP_OFFLOAD #include <sys/param.h> #include <sys/systm.h> #include <sys/fcntl.h> #include <sys/kernel.h> #include <sys/limits.h> #include <sys/ktr.h> #include <sys/lock.h> #include <sys/mbuf.h> #include <sys/mutex.h> #include <sys/sockstate.h> #include <sys/sockopt.h> #include <sys/socket.h> #include <sys/socketvar.h> #include <sys/sockbuf.h> #include <sys/sysctl.h> #include <sys/syslog.h> #include <sys/protosw.h> #include <sys/priv.h> #include <sys/sglist.h> #include <sys/taskqueue.h> #include <net/if.h> #include <net/if_var.h> #include <net/ethernet.h> #include <net/route.h> #include <netinet/in.h> #include <netinet/in_pcb.h> #include <netinet/in_systm.h> #include <netinet/in_var.h> #include <netinet/ip.h> #define TCPSTATES #include <netinet/tcp_fsm.h> #include <netinet/tcp_var.h> #include <netinet/toecore.h> #include <netinet/tcp_seq.h> #include <netinet/tcp_timer.h> #include <net/route.h> #include "cxgb_include.h" #include "ulp/tom/cxgb_l2t.h" #include "ulp/tom/cxgb_tom.h" #include "ulp/tom/cxgb_toepcb.h" VNET_DECLARE(int, tcp_do_autosndbuf); #define V_tcp_do_autosndbuf VNET(tcp_do_autosndbuf) VNET_DECLARE(int, tcp_autosndbuf_inc); #define V_tcp_autosndbuf_inc VNET(tcp_autosndbuf_inc) VNET_DECLARE(int, tcp_autosndbuf_max); #define V_tcp_autosndbuf_max VNET(tcp_autosndbuf_max) VNET_DECLARE(int, tcp_do_autorcvbuf); #define V_tcp_do_autorcvbuf VNET(tcp_do_autorcvbuf) VNET_DECLARE(int, tcp_autorcvbuf_inc); #define V_tcp_autorcvbuf_inc VNET(tcp_autorcvbuf_inc) VNET_DECLARE(int, tcp_autorcvbuf_max); #define V_tcp_autorcvbuf_max VNET(tcp_autorcvbuf_max) extern int always_keepalive; /* * For ULP connections HW may add headers, e.g., for digests, that aren't part * of the messages sent by the host but that are part of the TCP payload and * therefore consume TCP sequence space. Tx connection parameters that * operate in TCP sequence space are affected by the HW additions and need to * compensate for them to accurately track TCP sequence numbers. This array * contains the compensating extra lengths for ULP packets. It is indexed by * a packet's ULP submode. */ const unsigned int t3_ulp_extra_len[] = {0, 4, 4, 8}; /* * Max receive window supported by HW in bytes. Only a small part of it can * be set through option0, the rest needs to be set through RX_DATA_ACK. */ #define MAX_RCV_WND ((1U << 27) - 1) /* * Min receive window. We want it to be large enough to accommodate receive * coalescing, handle jumbo frames, and not trigger sender SWS avoidance. */ #define MIN_RCV_WND (24 * 1024U) #define INP_TOS(inp) ((inp_ip_tos_get(inp) >> 2) & M_TOS) static void t3_release_offload_resources(struct toepcb *); static void send_reset(struct toepcb *toep); /* * Called after the last CPL for the toepcb has been received. * * The inp must be wlocked on entry and is unlocked (or maybe destroyed) by the * time this function exits. */ static int toepcb_release(struct toepcb *toep) { struct inpcb *inp = toep->tp_inp; struct toedev *tod = toep->tp_tod; struct tom_data *td = t3_tomdata(tod); int rc; INP_WLOCK_ASSERT(inp); KASSERT(!(toep->tp_flags & TP_CPL_DONE), ("%s: double release?", __func__)); CTR2(KTR_CXGB, "%s: tid %d", __func__, toep->tp_tid); toep->tp_flags |= TP_CPL_DONE; toep->tp_inp = NULL; mtx_lock(&td->toep_list_lock); TAILQ_REMOVE(&td->toep_list, toep, link); mtx_unlock(&td->toep_list_lock); if (!(toep->tp_flags & TP_ATTACHED)) t3_release_offload_resources(toep); rc = in_pcbrele_wlocked(inp); if (!rc) INP_WUNLOCK(inp); return (rc); } /* * One sided detach. The tcpcb is going away and we need to unhook the toepcb * hanging off it. If the TOE driver is also done with the toepcb we'll release * all offload resources. */ static void toepcb_detach(struct inpcb *inp) { struct toepcb *toep; struct tcpcb *tp; KASSERT(inp, ("%s: inp is NULL", __func__)); INP_WLOCK_ASSERT(inp); tp = intotcpcb(inp); toep = tp->t_toe; KASSERT(toep != NULL, ("%s: toep is NULL", __func__)); KASSERT(toep->tp_flags & TP_ATTACHED, ("%s: not attached", __func__)); CTR6(KTR_CXGB, "%s: %s %u, toep %p, inp %p, tp %p", __func__, tp->t_state == TCPS_SYN_SENT ? "atid" : "tid", toep->tp_tid, toep, inp, tp); tp->t_toe = NULL; tp->t_flags &= ~TF_TOE; toep->tp_flags &= ~TP_ATTACHED; if (toep->tp_flags & TP_CPL_DONE) t3_release_offload_resources(toep); } void t3_pcb_detach(struct toedev *tod __unused, struct tcpcb *tp) { toepcb_detach(tp->t_inpcb); } static int alloc_atid(struct tid_info *t, void *ctx) { int atid = -1; mtx_lock(&t->atid_lock); if (t->afree) { union active_open_entry *p = t->afree; atid = (p - t->atid_tab) + t->atid_base; t->afree = p->next; p->ctx = ctx; t->atids_in_use++; } mtx_unlock(&t->atid_lock); return (atid); } static void free_atid(struct tid_info *t, int atid) { union active_open_entry *p = atid2entry(t, atid); mtx_lock(&t->atid_lock); p->next = t->afree; t->afree = p; t->atids_in_use--; mtx_unlock(&t->atid_lock); } void insert_tid(struct tom_data *td, void *ctx, unsigned int tid) { struct tid_info *t = &td->tid_maps; t->tid_tab[tid] = ctx; atomic_add_int(&t->tids_in_use, 1); } void update_tid(struct tom_data *td, void *ctx, unsigned int tid) { struct tid_info *t = &td->tid_maps; t->tid_tab[tid] = ctx; } void remove_tid(struct tom_data *td, unsigned int tid) { struct tid_info *t = &td->tid_maps; t->tid_tab[tid] = NULL; atomic_add_int(&t->tids_in_use, -1); } /* use ctx as a next pointer in the tid release list */ void queue_tid_release(struct toedev *tod, unsigned int tid) { struct tom_data *td = t3_tomdata(tod); void **p = &td->tid_maps.tid_tab[tid]; struct adapter *sc = tod->tod_softc; mtx_lock(&td->tid_release_lock); *p = td->tid_release_list; td->tid_release_list = p; if (!*p) taskqueue_enqueue(sc->tq, &td->tid_release_task); mtx_unlock(&td->tid_release_lock); } /* * Populate a TID_RELEASE WR. */ static inline void mk_tid_release(struct cpl_tid_release *cpl, unsigned int tid) { cpl->wr.wrh_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); OPCODE_TID(cpl) = htonl(MK_OPCODE_TID(CPL_TID_RELEASE, tid)); } void release_tid(struct toedev *tod, unsigned int tid, int qset) { struct tom_data *td = t3_tomdata(tod); struct adapter *sc = tod->tod_softc; struct mbuf *m; struct cpl_tid_release *cpl; #ifdef INVARIANTS struct tid_info *t = &td->tid_maps; #endif KASSERT(tid < t->ntids, ("%s: tid=%d, ntids=%d", __func__, tid, t->ntids)); m = M_GETHDR_OFLD(qset, CPL_PRIORITY_CONTROL, cpl); if (m) { mk_tid_release(cpl, tid); t3_offload_tx(sc, m); remove_tid(td, tid); } else queue_tid_release(tod, tid); } void t3_process_tid_release_list(void *data, int pending) { struct mbuf *m; struct tom_data *td = data; struct adapter *sc = td->tod.tod_softc; mtx_lock(&td->tid_release_lock); while (td->tid_release_list) { void **p = td->tid_release_list; unsigned int tid = p - td->tid_maps.tid_tab; struct cpl_tid_release *cpl; td->tid_release_list = (void **)*p; m = M_GETHDR_OFLD(0, CPL_PRIORITY_CONTROL, cpl); /* qs 0 here */ if (m == NULL) break; /* XXX: who reschedules the release task? */ mtx_unlock(&td->tid_release_lock); mk_tid_release(cpl, tid); t3_offload_tx(sc, m); remove_tid(td, tid); mtx_lock(&td->tid_release_lock); } mtx_unlock(&td->tid_release_lock); } static void close_conn(struct adapter *sc, struct toepcb *toep) { struct mbuf *m; struct cpl_close_con_req *req; if (toep->tp_flags & TP_FIN_SENT) return; m = M_GETHDR_OFLD(toep->tp_qset, CPL_PRIORITY_DATA, req); if (m == NULL) CXGB_UNIMPLEMENTED(); req->wr.wrh_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_CLOSE_CON)); req->wr.wrh_lo = htonl(V_WR_TID(toep->tp_tid)); OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_CLOSE_CON_REQ, toep->tp_tid)); req->rsvd = 0; toep->tp_flags |= TP_FIN_SENT; t3_offload_tx(sc, m); } static inline void make_tx_data_wr(struct socket *so, struct tx_data_wr *req, int len, struct mbuf *tail) { struct tcpcb *tp = so_sototcpcb(so); struct toepcb *toep = tp->t_toe; struct sockbuf *snd; inp_lock_assert(tp->t_inpcb); snd = so_sockbuf_snd(so); req->wr.wrh_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_TX_DATA)); req->wr.wrh_lo = htonl(V_WR_TID(toep->tp_tid)); /* len includes the length of any HW ULP additions */ req->len = htonl(len); req->param = htonl(V_TX_PORT(toep->tp_l2t->smt_idx)); /* V_TX_ULP_SUBMODE sets both the mode and submode */ req->flags = htonl(V_TX_ULP_SUBMODE(toep->tp_ulp_mode) | V_TX_URG(0) | V_TX_SHOVE(!(tp->t_flags & TF_MORETOCOME) && (tail ? 0 : 1))); req->sndseq = htonl(tp->snd_nxt); if (__predict_false((toep->tp_flags & TP_DATASENT) == 0)) { struct adapter *sc = toep->tp_tod->tod_softc; int cpu_idx = sc->rrss_map[toep->tp_qset]; req->flags |= htonl(V_TX_ACK_PAGES(2) | F_TX_INIT | V_TX_CPU_IDX(cpu_idx)); /* Sendbuffer is in units of 32KB. */ if (V_tcp_do_autosndbuf && snd->sb_flags & SB_AUTOSIZE) req->param |= htonl(V_TX_SNDBUF(VNET(tcp_autosndbuf_max) >> 15)); else req->param |= htonl(V_TX_SNDBUF(snd->sb_hiwat >> 15)); toep->tp_flags |= TP_DATASENT; } } /* * TOM_XXX_DUPLICATION sgl_len, calc_tx_descs, calc_tx_descs_ofld, mbuf_wrs, etc. * TOM_XXX_MOVE to some common header file. */ /* * IMM_LEN: # of bytes that can be tx'd as immediate data. There are 16 flits * in a tx desc; subtract 3 for tx_data_wr (including the WR header), and 1 more * for the second gen bit flit. This leaves us with 12 flits. * * descs_to_sgllen: # of SGL entries that can fit into the given # of tx descs. * The first desc has a tx_data_wr (which includes the WR header), the rest have * the WR header only. All descs have the second gen bit flit. * * sgllen_to_descs: # of tx descs used up by an sgl of given length. The first * desc has a tx_data_wr (which includes the WR header), the rest have the WR * header only. All descs have the second gen bit flit. * * flits_to_sgllen: # of SGL entries that can be fit in the given # of flits. * */ #define IMM_LEN 96 static int descs_to_sgllen[TX_MAX_DESC + 1] = {0, 8, 17, 26, 35}; static int sgllen_to_descs[TX_MAX_SEGS] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, /* 0 - 9 */ 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, /* 10 - 19 */ 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, /* 20 - 29 */ 4, 4, 4, 4, 4, 4 /* 30 - 35 */ }; #if 0 static int flits_to_sgllen[TX_DESC_FLITS + 1] = { 0, 0, 1, 2, 2, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 10 }; #endif #if SGE_NUM_GENBITS != 2 #error "SGE_NUM_GENBITS really must be 2" #endif int t3_push_frames(struct socket *so, int req_completion) { struct tcpcb *tp = so_sototcpcb(so); struct toepcb *toep = tp->t_toe; struct mbuf *m0, *sndptr, *m; struct toedev *tod = toep->tp_tod; struct adapter *sc = tod->tod_softc; int bytes, ndesc, total_bytes = 0, mlen; struct sockbuf *snd; struct sglist *sgl; struct ofld_hdr *oh; caddr_t dst; struct tx_data_wr *wr; inp_lock_assert(tp->t_inpcb); snd = so_sockbuf_snd(so); SOCKBUF_LOCK(snd); /* * Autosize the send buffer. */ if (snd->sb_flags & SB_AUTOSIZE && VNET(tcp_do_autosndbuf)) { if (sbused(snd) >= (snd->sb_hiwat / 8 * 7) && sbused(snd) < VNET(tcp_autosndbuf_max)) { if (!sbreserve_locked(snd, min(snd->sb_hiwat + VNET(tcp_autosndbuf_inc), VNET(tcp_autosndbuf_max)), so, curthread)) snd->sb_flags &= ~SB_AUTOSIZE; } } if (toep->tp_m_last && toep->tp_m_last == snd->sb_sndptr) sndptr = toep->tp_m_last->m_next; else sndptr = snd->sb_sndptr ? snd->sb_sndptr : snd->sb_mb; /* Nothing to send or no WRs available for sending data */ if (toep->tp_wr_avail == 0 || sndptr == NULL) goto out; /* Something to send and at least 1 WR available */ while (toep->tp_wr_avail && sndptr != NULL) { m0 = m_gethdr(M_NOWAIT, MT_DATA); if (m0 == NULL) break; oh = mtod(m0, struct ofld_hdr *); wr = (void *)(oh + 1); dst = (void *)(wr + 1); m0->m_pkthdr.len = m0->m_len = sizeof(*oh) + sizeof(*wr); oh->flags = V_HDR_CTRL(CPL_PRIORITY_DATA) | F_HDR_DF | V_HDR_QSET(toep->tp_qset); /* * Try to construct an immediate data WR if possible. Stuff as * much data into it as possible, one whole mbuf at a time. */ mlen = sndptr->m_len; ndesc = bytes = 0; while (mlen <= IMM_LEN - bytes) { bcopy(sndptr->m_data, dst, mlen); bytes += mlen; dst += mlen; if (!(sndptr = sndptr->m_next)) break; mlen = sndptr->m_len; } if (bytes) { /* Was able to fit 'bytes' bytes in an immediate WR */ ndesc = 1; make_tx_data_wr(so, wr, bytes, sndptr); m0->m_len += bytes; m0->m_pkthdr.len = m0->m_len; } else { int wr_avail = min(toep->tp_wr_avail, TX_MAX_DESC); /* Need to make an SGL */ sgl = sglist_alloc(descs_to_sgllen[wr_avail], M_NOWAIT); if (sgl == NULL) break; for (m = sndptr; m != NULL; m = m->m_next) { if ((mlen = m->m_len) > 0) { if (sglist_append(sgl, m->m_data, mlen)) break; } bytes += mlen; } sndptr = m; if (bytes == 0) { sglist_free(sgl); break; } ndesc = sgllen_to_descs[sgl->sg_nseg]; oh->flags |= F_HDR_SGL; oh->sgl = sgl; make_tx_data_wr(so, wr, bytes, sndptr); } oh->flags |= V_HDR_NDESC(ndesc); oh->plen = bytes; snd->sb_sndptr = sndptr; snd->sb_sndptroff += bytes; if (sndptr == NULL) { snd->sb_sndptr = snd->sb_mbtail; snd->sb_sndptroff -= snd->sb_mbtail->m_len; toep->tp_m_last = snd->sb_mbtail; } else toep->tp_m_last = NULL; total_bytes += bytes; toep->tp_wr_avail -= ndesc; toep->tp_wr_unacked += ndesc; if ((req_completion && toep->tp_wr_unacked == ndesc) || toep->tp_wr_unacked >= toep->tp_wr_max / 2) { wr->wr.wrh_hi |= htonl(F_WR_COMPL); toep->tp_wr_unacked = 0; } enqueue_wr(toep, m0); l2t_send(sc, m0, toep->tp_l2t); } out: SOCKBUF_UNLOCK(snd); if (sndptr == NULL && (toep->tp_flags & TP_SEND_FIN)) close_conn(sc, toep); return (total_bytes); } static int send_rx_credits(struct adapter *sc, struct toepcb *toep, int credits) { struct mbuf *m; struct cpl_rx_data_ack *req; uint32_t dack = F_RX_DACK_CHANGE | V_RX_DACK_MODE(1); m = M_GETHDR_OFLD(toep->tp_qset, CPL_PRIORITY_CONTROL, req); if (m == NULL) return (0); req->wr.wrh_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); req->wr.wrh_lo = 0; OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_RX_DATA_ACK, toep->tp_tid)); req->credit_dack = htonl(dack | V_RX_CREDITS(credits)); t3_offload_tx(sc, m); return (credits); } void t3_rcvd(struct toedev *tod, struct tcpcb *tp) { struct adapter *sc = tod->tod_softc; struct inpcb *inp = tp->t_inpcb; struct socket *so = inp->inp_socket; struct sockbuf *so_rcv = &so->so_rcv; struct toepcb *toep = tp->t_toe; int must_send; INP_WLOCK_ASSERT(inp); SOCKBUF_LOCK(so_rcv); KASSERT(toep->tp_enqueued >= sbused(so_rcv), ("%s: sbused(so_rcv) > enqueued", __func__)); toep->tp_rx_credits += toep->tp_enqueued - sbused(so_rcv); toep->tp_enqueued = sbused(so_rcv); SOCKBUF_UNLOCK(so_rcv); must_send = toep->tp_rx_credits + 16384 >= tp->rcv_wnd; if (must_send || toep->tp_rx_credits >= 15 * 1024) { int credits; credits = send_rx_credits(sc, toep, toep->tp_rx_credits); toep->tp_rx_credits -= credits; tp->rcv_wnd += credits; tp->rcv_adv += credits; } } static int do_rx_urg_notify(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; struct cpl_rx_urg_notify *hdr = mtod(m, void *); unsigned int tid = GET_TID(hdr); struct toepcb *toep = lookup_tid(&td->tid_maps, tid); log(LOG_ERR, "%s: tid %u inp %p", __func__, tid, toep->tp_inp); m_freem(m); return (0); } int t3_send_fin(struct toedev *tod, struct tcpcb *tp) { struct toepcb *toep = tp->t_toe; struct inpcb *inp = tp->t_inpcb; struct socket *so = inp_inpcbtosocket(inp); #if defined(KTR) unsigned int tid = toep->tp_tid; #endif INP_INFO_RLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); CTR4(KTR_CXGB, "%s: tid %d, toep %p, flags %x", __func__, tid, toep, toep->tp_flags); toep->tp_flags |= TP_SEND_FIN; t3_push_frames(so, 1); return (0); } int t3_tod_output(struct toedev *tod, struct tcpcb *tp) { struct inpcb *inp = tp->t_inpcb; struct socket *so = inp->inp_socket; t3_push_frames(so, 1); return (0); } /* What mtu_idx to use, given a 4-tuple and/or an MSS cap */ int find_best_mtu_idx(struct adapter *sc, struct in_conninfo *inc, int pmss) { unsigned short *mtus = &sc->params.mtus[0]; int i = 0, mss; KASSERT(inc != NULL || pmss > 0, ("%s: at least one of inc/pmss must be specified", __func__)); mss = inc ? tcp_mssopt(inc) : pmss; if (pmss > 0 && mss > pmss) mss = pmss; while (i < NMTUS - 1 && mtus[i + 1] <= mss + 40) ++i; return (i); } static inline void purge_wr_queue(struct toepcb *toep) { struct mbuf *m; struct ofld_hdr *oh; while ((m = mbufq_dequeue(&toep->wr_list)) != NULL) { oh = mtod(m, struct ofld_hdr *); if (oh->flags & F_HDR_SGL) sglist_free(oh->sgl); m_freem(m); } } /* * Release cxgb(4) and T3 resources held by an offload connection (TID, L2T * entry, etc.) */ static void t3_release_offload_resources(struct toepcb *toep) { struct toedev *tod = toep->tp_tod; struct tom_data *td = t3_tomdata(tod); /* * The TOM explicitly detaches its toepcb from the system's inp before * it releases the offload resources. */ if (toep->tp_inp) { panic("%s: inp %p still attached to toepcb %p", __func__, toep->tp_inp, toep); } if (toep->tp_wr_avail != toep->tp_wr_max) purge_wr_queue(toep); if (toep->tp_l2t) { l2t_release(td->l2t, toep->tp_l2t); toep->tp_l2t = NULL; } if (toep->tp_tid >= 0) release_tid(tod, toep->tp_tid, toep->tp_qset); toepcb_free(toep); } /* * Determine the receive window size for a socket. */ unsigned long select_rcv_wnd(struct socket *so) { unsigned long wnd; SOCKBUF_LOCK_ASSERT(&so->so_rcv); wnd = sbspace(&so->so_rcv); if (wnd < MIN_RCV_WND) wnd = MIN_RCV_WND; return min(wnd, MAX_RCV_WND); } int select_rcv_wscale(void) { int wscale = 0; unsigned long space = sb_max; if (space > MAX_RCV_WND) space = MAX_RCV_WND; while (wscale < TCP_MAX_WINSHIFT && (TCP_MAXWIN << wscale) < space) wscale++; return (wscale); } /* * Set up the socket for TCP offload. */ void offload_socket(struct socket *so, struct toepcb *toep) { struct toedev *tod = toep->tp_tod; struct tom_data *td = t3_tomdata(tod); struct inpcb *inp = sotoinpcb(so); struct tcpcb *tp = intotcpcb(inp); INP_WLOCK_ASSERT(inp); /* Update socket */ SOCKBUF_LOCK(&so->so_snd); so_sockbuf_snd(so)->sb_flags |= SB_NOCOALESCE; SOCKBUF_UNLOCK(&so->so_snd); SOCKBUF_LOCK(&so->so_rcv); so_sockbuf_rcv(so)->sb_flags |= SB_NOCOALESCE; SOCKBUF_UNLOCK(&so->so_rcv); /* Update TCP PCB */ tp->tod = toep->tp_tod; tp->t_toe = toep; tp->t_flags |= TF_TOE; /* Install an extra hold on inp */ toep->tp_inp = inp; toep->tp_flags |= TP_ATTACHED; in_pcbref(inp); /* Add the TOE PCB to the active list */ mtx_lock(&td->toep_list_lock); TAILQ_INSERT_HEAD(&td->toep_list, toep, link); mtx_unlock(&td->toep_list_lock); } /* This is _not_ the normal way to "unoffload" a socket. */ void undo_offload_socket(struct socket *so) { struct inpcb *inp = sotoinpcb(so); struct tcpcb *tp = intotcpcb(inp); struct toepcb *toep = tp->t_toe; struct toedev *tod = toep->tp_tod; struct tom_data *td = t3_tomdata(tod); INP_WLOCK_ASSERT(inp); so_sockbuf_snd(so)->sb_flags &= ~SB_NOCOALESCE; so_sockbuf_rcv(so)->sb_flags &= ~SB_NOCOALESCE; tp->tod = NULL; tp->t_toe = NULL; tp->t_flags &= ~TF_TOE; toep->tp_inp = NULL; toep->tp_flags &= ~TP_ATTACHED; if (in_pcbrele_wlocked(inp)) panic("%s: inp freed.", __func__); mtx_lock(&td->toep_list_lock); TAILQ_REMOVE(&td->toep_list, toep, link); mtx_unlock(&td->toep_list_lock); } /* * Socket could be a listening socket, and we may not have a toepcb at all at * this time. */ uint32_t calc_opt0h(struct socket *so, int mtu_idx, int rscale, struct l2t_entry *e) { uint32_t opt0h = F_TCAM_BYPASS | V_WND_SCALE(rscale) | V_MSS_IDX(mtu_idx); if (so != NULL) { struct inpcb *inp = sotoinpcb(so); struct tcpcb *tp = intotcpcb(inp); int keepalive = always_keepalive || so_options_get(so) & SO_KEEPALIVE; opt0h |= V_NAGLE((tp->t_flags & TF_NODELAY) == 0); opt0h |= V_KEEP_ALIVE(keepalive != 0); } if (e != NULL) opt0h |= V_L2T_IDX(e->idx) | V_TX_CHANNEL(e->smt_idx); return (htobe32(opt0h)); } uint32_t calc_opt0l(struct socket *so, int rcv_bufsize) { uint32_t opt0l = V_ULP_MODE(ULP_MODE_NONE) | V_RCV_BUFSIZ(rcv_bufsize); KASSERT(rcv_bufsize <= M_RCV_BUFSIZ, ("%s: rcv_bufsize (%d) is too high", __func__, rcv_bufsize)); if (so != NULL) /* optional because no one cares about IP TOS */ opt0l |= V_TOS(INP_TOS(sotoinpcb(so))); return (htobe32(opt0l)); } /* * Convert an ACT_OPEN_RPL status to an errno. */ static int act_open_rpl_status_to_errno(int status) { switch (status) { case CPL_ERR_CONN_RESET: return (ECONNREFUSED); case CPL_ERR_ARP_MISS: return (EHOSTUNREACH); case CPL_ERR_CONN_TIMEDOUT: return (ETIMEDOUT); case CPL_ERR_TCAM_FULL: return (EAGAIN); case CPL_ERR_CONN_EXIST: log(LOG_ERR, "ACTIVE_OPEN_RPL: 4-tuple in use\n"); return (EAGAIN); default: return (EIO); } } /* * Return whether a failed active open has allocated a TID */ static inline int act_open_has_tid(int status) { return status != CPL_ERR_TCAM_FULL && status != CPL_ERR_CONN_EXIST && status != CPL_ERR_ARP_MISS; } /* * Active open failed. */ static int do_act_open_rpl(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; struct toedev *tod = &td->tod; struct cpl_act_open_rpl *rpl = mtod(m, void *); unsigned int atid = G_TID(ntohl(rpl->atid)); struct toepcb *toep = lookup_atid(&td->tid_maps, atid); struct inpcb *inp = toep->tp_inp; int s = rpl->status, rc; CTR3(KTR_CXGB, "%s: atid %u, status %u ", __func__, atid, s); free_atid(&td->tid_maps, atid); toep->tp_tid = -1; if (act_open_has_tid(s)) queue_tid_release(tod, GET_TID(rpl)); rc = act_open_rpl_status_to_errno(s); if (rc != EAGAIN) INP_INFO_RLOCK(&V_tcbinfo); INP_WLOCK(inp); toe_connect_failed(tod, inp, rc); toepcb_release(toep); /* unlocks inp */ if (rc != EAGAIN) INP_INFO_RUNLOCK(&V_tcbinfo); m_freem(m); return (0); } /* * Send an active open request. * * State of affairs on entry: * soisconnecting (so_state |= SS_ISCONNECTING) * tcbinfo not locked (this has changed - used to be WLOCKed) * inp WLOCKed * tp->t_state = TCPS_SYN_SENT * rtalloc1, RT_UNLOCK on rt. */ int t3_connect(struct toedev *tod, struct socket *so, struct rtentry *rt, struct sockaddr *nam) { struct mbuf *m = NULL; struct l2t_entry *e = NULL; struct tom_data *td = t3_tomdata(tod); struct adapter *sc = tod->tod_softc; struct cpl_act_open_req *cpl; struct inpcb *inp = sotoinpcb(so); struct tcpcb *tp = intotcpcb(inp); struct toepcb *toep; int atid = -1, mtu_idx, rscale, cpu_idx, qset; struct sockaddr *gw; struct ifnet *ifp = rt->rt_ifp; struct port_info *pi = ifp->if_softc; /* XXX wrong for VLAN etc. */ INP_WLOCK_ASSERT(inp); toep = toepcb_alloc(tod); if (toep == NULL) goto failed; atid = alloc_atid(&td->tid_maps, toep); if (atid < 0) goto failed; qset = pi->first_qset + (arc4random() % pi->nqsets); m = M_GETHDR_OFLD(qset, CPL_PRIORITY_CONTROL, cpl); if (m == NULL) goto failed; gw = rt->rt_flags & RTF_GATEWAY ? rt->rt_gateway : nam; e = t3_l2t_get(pi, ifp, gw); if (e == NULL) goto failed; toep->tp_l2t = e; toep->tp_tid = atid; /* used to double check response */ toep->tp_qset = qset; SOCKBUF_LOCK(&so->so_rcv); /* opt0 rcv_bufsiz initially, assumes its normal meaning later */ toep->tp_rx_credits = min(select_rcv_wnd(so) >> 10, M_RCV_BUFSIZ); SOCKBUF_UNLOCK(&so->so_rcv); offload_socket(so, toep); /* * The kernel sets request_r_scale based on sb_max whereas we need to * take hardware's MAX_RCV_WND into account too. This is normally a * no-op as MAX_RCV_WND is much larger than the default sb_max. */ if (tp->t_flags & TF_REQ_SCALE) rscale = tp->request_r_scale = select_rcv_wscale(); else rscale = 0; mtu_idx = find_best_mtu_idx(sc, &inp->inp_inc, 0); cpu_idx = sc->rrss_map[qset]; cpl->wr.wrh_hi = htobe32(V_WR_OP(FW_WROPCODE_FORWARD)); cpl->wr.wrh_lo = 0; OPCODE_TID(cpl) = htobe32(MK_OPCODE_TID(CPL_ACT_OPEN_REQ, atid)); inp_4tuple_get(inp, &cpl->local_ip, &cpl->local_port, &cpl->peer_ip, &cpl->peer_port); cpl->opt0h = calc_opt0h(so, mtu_idx, rscale, e); cpl->opt0l = calc_opt0l(so, toep->tp_rx_credits); cpl->params = 0; cpl->opt2 = calc_opt2(cpu_idx); CTR5(KTR_CXGB, "%s: atid %u (%s), toep %p, inp %p", __func__, toep->tp_tid, tcpstates[tp->t_state], toep, inp); if (l2t_send(sc, m, e) == 0) return (0); undo_offload_socket(so); failed: CTR5(KTR_CXGB, "%s: FAILED, atid %d, toep %p, l2te %p, mbuf %p", __func__, atid, toep, e, m); if (atid >= 0) free_atid(&td->tid_maps, atid); if (e) l2t_release(td->l2t, e); if (toep) toepcb_free(toep); m_freem(m); return (ENOMEM); } /* * Send an ABORT_REQ message. Cannot fail. This routine makes sure we do not * send multiple ABORT_REQs for the same connection and also that we do not try * to send a message after the connection has closed. */ static void send_reset(struct toepcb *toep) { struct cpl_abort_req *req; unsigned int tid = toep->tp_tid; struct inpcb *inp = toep->tp_inp; struct socket *so = inp->inp_socket; struct tcpcb *tp = intotcpcb(inp); struct toedev *tod = toep->tp_tod; struct adapter *sc = tod->tod_softc; struct mbuf *m; INP_INFO_RLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); CTR4(KTR_CXGB, "%s: tid %d, toep %p (%x)", __func__, tid, toep, toep->tp_flags); if (toep->tp_flags & TP_ABORT_SHUTDOWN) return; toep->tp_flags |= (TP_ABORT_RPL_PENDING | TP_ABORT_SHUTDOWN); /* Purge the send queue */ sbflush(so_sockbuf_snd(so)); purge_wr_queue(toep); m = M_GETHDR_OFLD(toep->tp_qset, CPL_PRIORITY_DATA, req); if (m == NULL) CXGB_UNIMPLEMENTED(); req->wr.wrh_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_REQ)); req->wr.wrh_lo = htonl(V_WR_TID(tid)); OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_ABORT_REQ, tid)); req->rsvd0 = htonl(tp->snd_nxt); req->rsvd1 = !(toep->tp_flags & TP_DATASENT); req->cmd = CPL_ABORT_SEND_RST; if (tp->t_state == TCPS_SYN_SENT) (void )mbufq_enqueue(&toep->out_of_order_queue, m); /* defer */ else l2t_send(sc, m, toep->tp_l2t); } int t3_send_rst(struct toedev *tod __unused, struct tcpcb *tp) { send_reset(tp->t_toe); return (0); } /* * Handler for RX_DATA CPL messages. */ static int do_rx_data(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; struct cpl_rx_data *hdr = mtod(m, void *); unsigned int tid = GET_TID(hdr); struct toepcb *toep = lookup_tid(&td->tid_maps, tid); struct inpcb *inp = toep->tp_inp; struct tcpcb *tp; struct socket *so; struct sockbuf *so_rcv; /* Advance over CPL */ m_adj(m, sizeof(*hdr)); /* XXX: revisit. This comes from the T4 TOM */ if (__predict_false(inp == NULL)) { /* * do_pass_establish failed and must be attempting to abort the * connection. Meanwhile, the T4 has sent us data for such a * connection. */ #ifdef notyet KASSERT(toepcb_flag(toep, TPF_ABORT_SHUTDOWN), ("%s: inp NULL and tid isn't being aborted", __func__)); #endif m_freem(m); return (0); } INP_WLOCK(inp); if (inp->inp_flags & (INP_DROPPED | INP_TIMEWAIT)) { CTR4(KTR_CXGB, "%s: tid %u, rx (%d bytes), inp_flags 0x%x", __func__, tid, m->m_pkthdr.len, inp->inp_flags); INP_WUNLOCK(inp); m_freem(m); return (0); } if (__predict_false(hdr->dack_mode != toep->tp_delack_mode)) toep->tp_delack_mode = hdr->dack_mode; tp = intotcpcb(inp); #ifdef INVARIANTS if (__predict_false(tp->rcv_nxt != be32toh(hdr->seq))) { log(LOG_ERR, "%s: unexpected seq# %x for TID %u, rcv_nxt %x\n", __func__, be32toh(hdr->seq), toep->tp_tid, tp->rcv_nxt); } #endif tp->rcv_nxt += m->m_pkthdr.len; KASSERT(tp->rcv_wnd >= m->m_pkthdr.len, ("%s: negative window size", __func__)); tp->rcv_wnd -= m->m_pkthdr.len; tp->t_rcvtime = ticks; so = inp->inp_socket; so_rcv = &so->so_rcv; SOCKBUF_LOCK(so_rcv); if (__predict_false(so_rcv->sb_state & SBS_CANTRCVMORE)) { CTR3(KTR_CXGB, "%s: tid %u, excess rx (%d bytes)", __func__, tid, m->m_pkthdr.len); SOCKBUF_UNLOCK(so_rcv); INP_WUNLOCK(inp); INP_INFO_RLOCK(&V_tcbinfo); INP_WLOCK(inp); tp = tcp_drop(tp, ECONNRESET); if (tp) INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); m_freem(m); return (0); } /* receive buffer autosize */ if (so_rcv->sb_flags & SB_AUTOSIZE && V_tcp_do_autorcvbuf && so_rcv->sb_hiwat < V_tcp_autorcvbuf_max && (m->m_pkthdr.len > (sbspace(so_rcv) / 8 * 7) || tp->rcv_wnd < 32768)) { unsigned int hiwat = so_rcv->sb_hiwat; unsigned int newsize = min(hiwat + V_tcp_autorcvbuf_inc, V_tcp_autorcvbuf_max); if (!sbreserve_locked(so_rcv, newsize, so, NULL)) so_rcv->sb_flags &= ~SB_AUTOSIZE; else toep->tp_rx_credits += newsize - hiwat; } toep->tp_enqueued += m->m_pkthdr.len; sbappendstream_locked(so_rcv, m, 0); sorwakeup_locked(so); SOCKBUF_UNLOCK_ASSERT(so_rcv); INP_WUNLOCK(inp); return (0); } /* * Handler for PEER_CLOSE CPL messages. */ static int do_peer_close(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; const struct cpl_peer_close *hdr = mtod(m, void *); unsigned int tid = GET_TID(hdr); struct toepcb *toep = lookup_tid(&td->tid_maps, tid); struct inpcb *inp = toep->tp_inp; struct tcpcb *tp; struct socket *so; INP_INFO_RLOCK(&V_tcbinfo); INP_WLOCK(inp); tp = intotcpcb(inp); CTR5(KTR_CXGB, "%s: tid %u (%s), toep_flags 0x%x, inp %p", __func__, tid, tp ? tcpstates[tp->t_state] : "no tp" , toep->tp_flags, inp); if (toep->tp_flags & TP_ABORT_RPL_PENDING) goto done; so = inp_inpcbtosocket(inp); socantrcvmore(so); tp->rcv_nxt++; switch (tp->t_state) { case TCPS_SYN_RECEIVED: tp->t_starttime = ticks; /* FALLTHROUGH */ case TCPS_ESTABLISHED: tp->t_state = TCPS_CLOSE_WAIT; break; case TCPS_FIN_WAIT_1: tp->t_state = TCPS_CLOSING; break; case TCPS_FIN_WAIT_2: tcp_twstart(tp); INP_UNLOCK_ASSERT(inp); /* safe, we have a ref on the inp */ INP_INFO_RUNLOCK(&V_tcbinfo); INP_WLOCK(inp); toepcb_release(toep); /* no more CPLs expected */ m_freem(m); return (0); default: log(LOG_ERR, "%s: TID %u received PEER_CLOSE in bad state %d\n", __func__, toep->tp_tid, tp->t_state); } done: INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); m_freem(m); return (0); } /* * Handler for CLOSE_CON_RPL CPL messages. peer ACK to our FIN received. */ static int do_close_con_rpl(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; const struct cpl_close_con_rpl *rpl = mtod(m, void *); unsigned int tid = GET_TID(rpl); struct toepcb *toep = lookup_tid(&td->tid_maps, tid); struct inpcb *inp = toep->tp_inp; struct tcpcb *tp; struct socket *so; INP_INFO_RLOCK(&V_tcbinfo); INP_WLOCK(inp); tp = intotcpcb(inp); CTR4(KTR_CXGB, "%s: tid %u (%s), toep_flags 0x%x", __func__, tid, tp ? tcpstates[tp->t_state] : "no tp", toep->tp_flags); if ((toep->tp_flags & TP_ABORT_RPL_PENDING)) goto done; so = inp_inpcbtosocket(inp); tp->snd_una = ntohl(rpl->snd_nxt) - 1; /* exclude FIN */ switch (tp->t_state) { case TCPS_CLOSING: tcp_twstart(tp); release: INP_UNLOCK_ASSERT(inp); /* safe, we have a ref on the inp */ INP_INFO_RUNLOCK(&V_tcbinfo); INP_WLOCK(inp); toepcb_release(toep); /* no more CPLs expected */ m_freem(m); return (0); case TCPS_LAST_ACK: if (tcp_close(tp)) INP_WUNLOCK(inp); goto release; case TCPS_FIN_WAIT_1: if (so->so_rcv.sb_state & SBS_CANTRCVMORE) soisdisconnected(so); tp->t_state = TCPS_FIN_WAIT_2; break; default: log(LOG_ERR, "%s: TID %u received CLOSE_CON_RPL in bad state %d\n", __func__, toep->tp_tid, tp->t_state); } done: INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); m_freem(m); return (0); } static int do_smt_write_rpl(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct cpl_smt_write_rpl *rpl = mtod(m, void *); if (rpl->status != CPL_ERR_NONE) { log(LOG_ERR, "Unexpected SMT_WRITE_RPL status %u for entry %u\n", rpl->status, GET_TID(rpl)); } m_freem(m); return (0); } static int do_set_tcb_rpl(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct cpl_set_tcb_rpl *rpl = mtod(m, void *); if (rpl->status != CPL_ERR_NONE) { log(LOG_ERR, "Unexpected SET_TCB_RPL status %u for tid %u\n", rpl->status, GET_TID(rpl)); } m_freem(m); return (0); } /* * Handle an ABORT_RPL_RSS CPL message. */ static int do_abort_rpl(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; const struct cpl_abort_rpl_rss *rpl = mtod(m, void *); unsigned int tid = GET_TID(rpl); struct toepcb *toep = lookup_tid(&td->tid_maps, tid); struct inpcb *inp; /* * Ignore replies to post-close aborts indicating that the abort was * requested too late. These connections are terminated when we get * PEER_CLOSE or CLOSE_CON_RPL and by the time the abort_rpl_rss * arrives the TID is either no longer used or it has been recycled. */ if (rpl->status == CPL_ERR_ABORT_FAILED) { m_freem(m); return (0); } if (toep->tp_flags & TP_IS_A_SYNQ_ENTRY) return (do_abort_rpl_synqe(qs, r, m)); CTR4(KTR_CXGB, "%s: tid %d, toep %p, status %d", __func__, tid, toep, rpl->status); inp = toep->tp_inp; INP_WLOCK(inp); if (toep->tp_flags & TP_ABORT_RPL_PENDING) { if (!(toep->tp_flags & TP_ABORT_RPL_RCVD)) { toep->tp_flags |= TP_ABORT_RPL_RCVD; INP_WUNLOCK(inp); } else { toep->tp_flags &= ~TP_ABORT_RPL_RCVD; toep->tp_flags &= TP_ABORT_RPL_PENDING; toepcb_release(toep); /* no more CPLs expected */ } } m_freem(m); return (0); } /* * Convert the status code of an ABORT_REQ into a FreeBSD error code. */ static int abort_status_to_errno(struct tcpcb *tp, int abort_reason) { switch (abort_reason) { case CPL_ERR_BAD_SYN: case CPL_ERR_CONN_RESET: return (tp->t_state == TCPS_CLOSE_WAIT ? EPIPE : ECONNRESET); case CPL_ERR_XMIT_TIMEDOUT: case CPL_ERR_PERSIST_TIMEDOUT: case CPL_ERR_FINWAIT2_TIMEDOUT: case CPL_ERR_KEEPALIVE_TIMEDOUT: return (ETIMEDOUT); default: return (EIO); } } /* * Returns whether an ABORT_REQ_RSS message is a negative advice. */ static inline int is_neg_adv_abort(unsigned int status) { return status == CPL_ERR_RTX_NEG_ADVICE || status == CPL_ERR_PERSIST_NEG_ADVICE; } void send_abort_rpl(struct toedev *tod, int tid, int qset) { struct mbuf *reply; struct cpl_abort_rpl *rpl; struct adapter *sc = tod->tod_softc; reply = M_GETHDR_OFLD(qset, CPL_PRIORITY_DATA, rpl); if (!reply) CXGB_UNIMPLEMENTED(); rpl->wr.wrh_hi = htonl(V_WR_OP(FW_WROPCODE_OFLD_HOST_ABORT_CON_RPL)); rpl->wr.wrh_lo = htonl(V_WR_TID(tid)); OPCODE_TID(rpl) = htonl(MK_OPCODE_TID(CPL_ABORT_RPL, tid)); rpl->cmd = CPL_ABORT_NO_RST; t3_offload_tx(sc, reply); } /* * Handle an ABORT_REQ_RSS CPL message. If we're waiting for an ABORT_RPL we * ignore this request except that we need to reply to it. */ static int do_abort_req(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; struct toedev *tod = &td->tod; const struct cpl_abort_req_rss *req = mtod(m, void *); unsigned int tid = GET_TID(req); struct toepcb *toep = lookup_tid(&td->tid_maps, tid); struct inpcb *inp; struct tcpcb *tp; struct socket *so; int qset = toep->tp_qset; if (is_neg_adv_abort(req->status)) { CTR4(KTR_CXGB, "%s: negative advice %d for tid %u (%x)", __func__, req->status, tid, toep->tp_flags); m_freem(m); return (0); } if (toep->tp_flags & TP_IS_A_SYNQ_ENTRY) return (do_abort_req_synqe(qs, r, m)); inp = toep->tp_inp; INP_INFO_RLOCK(&V_tcbinfo); /* for tcp_close */ INP_WLOCK(inp); tp = intotcpcb(inp); so = inp->inp_socket; CTR6(KTR_CXGB, "%s: tid %u (%s), toep %p (%x), status %d", __func__, tid, tcpstates[tp->t_state], toep, toep->tp_flags, req->status); if (!(toep->tp_flags & TP_ABORT_REQ_RCVD)) { toep->tp_flags |= TP_ABORT_REQ_RCVD; toep->tp_flags |= TP_ABORT_SHUTDOWN; INP_WUNLOCK(inp); INP_INFO_RUNLOCK(&V_tcbinfo); m_freem(m); return (0); } toep->tp_flags &= ~TP_ABORT_REQ_RCVD; /* * If we'd sent a reset on this toep, we'll ignore this and clean up in * the T3's reply to our reset instead. */ if (toep->tp_flags & TP_ABORT_RPL_PENDING) { toep->tp_flags |= TP_ABORT_RPL_SENT; INP_WUNLOCK(inp); } else { so_error_set(so, abort_status_to_errno(tp, req->status)); tp = tcp_close(tp); if (tp == NULL) INP_WLOCK(inp); /* re-acquire */ toepcb_release(toep); /* no more CPLs expected */ } INP_INFO_RUNLOCK(&V_tcbinfo); send_abort_rpl(tod, tid, qset); m_freem(m); return (0); } static void assign_rxopt(struct tcpcb *tp, uint16_t tcpopt) { struct toepcb *toep = tp->t_toe; struct adapter *sc = toep->tp_tod->tod_softc; tp->t_maxseg = sc->params.mtus[G_TCPOPT_MSS(tcpopt)] - 40; if (G_TCPOPT_TSTAMP(tcpopt)) { tp->t_flags |= TF_RCVD_TSTMP; tp->t_flags |= TF_REQ_TSTMP; /* forcibly set */ tp->ts_recent = 0; /* XXX */ tp->ts_recent_age = tcp_ts_getticks(); } if (G_TCPOPT_SACK(tcpopt)) tp->t_flags |= TF_SACK_PERMIT; else tp->t_flags &= ~TF_SACK_PERMIT; if (G_TCPOPT_WSCALE_OK(tcpopt)) tp->t_flags |= TF_RCVD_SCALE; if ((tp->t_flags & (TF_RCVD_SCALE | TF_REQ_SCALE)) == (TF_RCVD_SCALE | TF_REQ_SCALE)) { tp->rcv_scale = tp->request_r_scale; tp->snd_scale = G_TCPOPT_SND_WSCALE(tcpopt); } } /* * The ISS and IRS are from after the exchange of SYNs and are off by 1. */ void make_established(struct socket *so, uint32_t cpl_iss, uint32_t cpl_irs, uint16_t cpl_tcpopt) { struct inpcb *inp = sotoinpcb(so); struct tcpcb *tp = intotcpcb(inp); struct toepcb *toep = tp->t_toe; long bufsize; uint32_t iss = be32toh(cpl_iss) - 1; /* true ISS */ uint32_t irs = be32toh(cpl_irs) - 1; /* true IRS */ uint16_t tcpopt = be16toh(cpl_tcpopt); INP_WLOCK_ASSERT(inp); tp->t_state = TCPS_ESTABLISHED; tp->t_starttime = ticks; TCPSTAT_INC(tcps_connects); CTR4(KTR_CXGB, "%s tid %u, toep %p, inp %p", tcpstates[tp->t_state], toep->tp_tid, toep, inp); tp->irs = irs; tcp_rcvseqinit(tp); tp->rcv_wnd = toep->tp_rx_credits << 10; tp->rcv_adv += tp->rcv_wnd; tp->last_ack_sent = tp->rcv_nxt; /* * If we were unable to send all rx credits via opt0, save the remainder * in rx_credits so that they can be handed over with the next credit * update. */ SOCKBUF_LOCK(&so->so_rcv); bufsize = select_rcv_wnd(so); SOCKBUF_UNLOCK(&so->so_rcv); toep->tp_rx_credits = bufsize - tp->rcv_wnd; tp->iss = iss; tcp_sendseqinit(tp); tp->snd_una = iss + 1; tp->snd_nxt = iss + 1; tp->snd_max = iss + 1; assign_rxopt(tp, tcpopt); soisconnected(so); } /* * Fill in the right TID for CPL messages waiting in the out-of-order queue * and send them to the TOE. */ static void fixup_and_send_ofo(struct toepcb *toep) { struct mbuf *m; struct toedev *tod = toep->tp_tod; struct adapter *sc = tod->tod_softc; struct inpcb *inp = toep->tp_inp; unsigned int tid = toep->tp_tid; inp_lock_assert(inp); while ((m = mbufq_dequeue(&toep->out_of_order_queue)) != NULL) { struct ofld_hdr *oh = mtod(m, void *); /* * A variety of messages can be waiting but the fields we'll * be touching are common to all so any message type will do. */ struct cpl_close_con_req *p = (void *)(oh + 1); p->wr.wrh_lo = htonl(V_WR_TID(tid)); OPCODE_TID(p) = htonl(MK_OPCODE_TID(p->ot.opcode, tid)); t3_offload_tx(sc, m); } } /* * Process a CPL_ACT_ESTABLISH message. */ static int do_act_establish(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; struct cpl_act_establish *req = mtod(m, void *); unsigned int tid = GET_TID(req); unsigned int atid = G_PASS_OPEN_TID(ntohl(req->tos_tid)); struct toepcb *toep = lookup_atid(&td->tid_maps, atid); struct inpcb *inp = toep->tp_inp; struct tcpcb *tp; struct socket *so; CTR3(KTR_CXGB, "%s: atid %u, tid %u", __func__, atid, tid); free_atid(&td->tid_maps, atid); INP_WLOCK(inp); tp = intotcpcb(inp); KASSERT(toep->tp_qset == qs->idx, ("%s qset mismatch %d %d", __func__, toep->tp_qset, qs->idx)); KASSERT(toep->tp_tid == atid, ("%s atid mismatch %d %d", __func__, toep->tp_tid, atid)); toep->tp_tid = tid; insert_tid(td, toep, tid); if (inp->inp_flags & INP_DROPPED) { /* socket closed by the kernel before hw told us it connected */ send_reset(toep); goto done; } KASSERT(tp->t_state == TCPS_SYN_SENT, ("TID %u expected TCPS_SYN_SENT, found %d.", tid, tp->t_state)); so = inp->inp_socket; make_established(so, req->snd_isn, req->rcv_isn, req->tcp_opt); /* * Now that we finally have a TID send any CPL messages that we had to * defer for lack of a TID. */ if (mbufq_len(&toep->out_of_order_queue)) fixup_and_send_ofo(toep); done: INP_WUNLOCK(inp); m_freem(m); return (0); } /* * Process an acknowledgment of WR completion. Advance snd_una and send the * next batch of work requests from the write queue. */ static void wr_ack(struct toepcb *toep, struct mbuf *m) { struct inpcb *inp = toep->tp_inp; struct tcpcb *tp; struct cpl_wr_ack *hdr = mtod(m, void *); struct socket *so; unsigned int credits = ntohs(hdr->credits); u32 snd_una = ntohl(hdr->snd_una); int bytes = 0; struct sockbuf *snd; struct mbuf *p; struct ofld_hdr *oh; inp_wlock(inp); tp = intotcpcb(inp); so = inp->inp_socket; toep->tp_wr_avail += credits; if (toep->tp_wr_unacked > toep->tp_wr_max - toep->tp_wr_avail) toep->tp_wr_unacked = toep->tp_wr_max - toep->tp_wr_avail; while (credits) { p = peek_wr(toep); if (__predict_false(!p)) { CTR5(KTR_CXGB, "%s: %u extra WR_ACK credits, " "tid %u, state %u, wr_avail %u", __func__, credits, toep->tp_tid, tp->t_state, toep->tp_wr_avail); log(LOG_ERR, "%u WR_ACK credits for TID %u with " "nothing pending, state %u wr_avail=%u\n", credits, toep->tp_tid, tp->t_state, toep->tp_wr_avail); break; } oh = mtod(p, struct ofld_hdr *); KASSERT(credits >= G_HDR_NDESC(oh->flags), ("%s: partial credits? %d %d", __func__, credits, G_HDR_NDESC(oh->flags))); dequeue_wr(toep); credits -= G_HDR_NDESC(oh->flags); bytes += oh->plen; if (oh->flags & F_HDR_SGL) sglist_free(oh->sgl); m_freem(p); } if (__predict_false(SEQ_LT(snd_una, tp->snd_una))) goto out_free; if (tp->snd_una != snd_una) { tp->snd_una = snd_una; tp->ts_recent_age = tcp_ts_getticks(); if (tp->snd_una == tp->snd_nxt) toep->tp_flags &= ~TP_TX_WAIT_IDLE; } snd = so_sockbuf_snd(so); if (bytes) { SOCKBUF_LOCK(snd); sbdrop_locked(snd, bytes); so_sowwakeup_locked(so); } if (snd->sb_sndptroff < sbused(snd)) t3_push_frames(so, 0); out_free: inp_wunlock(tp->t_inpcb); m_freem(m); } /* * Handler for TX_DATA_ACK CPL messages. */ static int do_wr_ack(struct sge_qset *qs, struct rsp_desc *r, struct mbuf *m) { struct adapter *sc = qs->adap; struct tom_data *td = sc->tom_softc; struct cpl_wr_ack *hdr = mtod(m, void *); unsigned int tid = GET_TID(hdr); struct toepcb *toep = lookup_tid(&td->tid_maps, tid); /* XXX bad race */ if (toep) wr_ack(toep, m); return (0); } void t3_init_cpl_io(struct adapter *sc) { t3_register_cpl_handler(sc, CPL_ACT_ESTABLISH, do_act_establish); t3_register_cpl_handler(sc, CPL_ACT_OPEN_RPL, do_act_open_rpl); t3_register_cpl_handler(sc, CPL_RX_URG_NOTIFY, do_rx_urg_notify); t3_register_cpl_handler(sc, CPL_RX_DATA, do_rx_data); t3_register_cpl_handler(sc, CPL_TX_DMA_ACK, do_wr_ack); t3_register_cpl_handler(sc, CPL_PEER_CLOSE, do_peer_close); t3_register_cpl_handler(sc, CPL_ABORT_REQ_RSS, do_abort_req); t3_register_cpl_handler(sc, CPL_ABORT_RPL_RSS, do_abort_rpl); t3_register_cpl_handler(sc, CPL_CLOSE_CON_RPL, do_close_con_rpl); t3_register_cpl_handler(sc, CPL_SMT_WRITE_RPL, do_smt_write_rpl); t3_register_cpl_handler(sc, CPL_SET_TCB_RPL, do_set_tcb_rpl); } #endif
isc
breunigs/keks
db/migrate/20130217083354_create_questions.rb
182
class CreateQuestions < ActiveRecord::Migration def change create_table :questions do |t| t.references :parent, :polymorphic => true t.timestamps end end end
isc
edonet/package
Edoner/expand_tabs_on_save.py
236
import sublime, sublime_plugin, os class ExpandTabsOnSave(sublime_plugin.EventListener): def on_pre_save(self, view): if view.settings().get('expand_tabs_on_save') == 1: view.window().run_command('expand_tabs')
isc
JavieChan/nanshaCity
yejin/templates/projectuserpayinfo.html
4678
<%inherit file="base.html" /> <div class="wrapper"> <input type="hidden" id="location" value="${location}" /> <!--导航--> <%include file="nav.html" args="on={'user': 'on'}" /> <!--右侧功能栏--> <div class="projects"> <div class="tabbox"> <div class="bread"> <%include file="bread_nav.html" args="location=location,ins=ins,suffix='账号详情',compress=True,remain=[('缴费账号', '/projectuserpay.html?location={}'.format(location))]"/> <div class="widget"> ##<a href="/projecturl.html?location=${location}&user=${account.user}&mobile=${account.mobile}" class="btnGraySmall">URL纪录</a> % if ins.is_allowed('update', 'user'): ##<input type="hidden" class="id" value="${account.user}" /> <button type="button" class="btnGraySmall" id="userinfoEdit">编辑</button> <button type="button" class="btnBlueSmall userinfoSave" id="userinfoPaySave" style="display: none;">保存</button> <button type="button" class="btnGraySmall" id="userinfoQuit" style="display: none;">取消</button> % endif <button type="button" class="btnGraySmall userinfoReback">返回</button> </div> </div> </div> <div class="tabbox ns_infouser" id="userinfo"> <div class="areabox"> <ul class="vertical"> <li> <label>账号:</label> ##<span class="veright" data-value="${account.user}" name="user" data-type="text">${account.user}</span> <span class="veright" data-value="" name="user" data-type="text"></span> </li> <li> <label>姓名:</label> ##<span class="veright" data-value="${pnuser.name}" name="name" data-type="text">${pnuser.name}</span> <span class="veright" data-value="" name="name" data-type="text"></span> </li> <li> <label>学号:</label> ##<span class="veright" data-value="${pnuser.number}" name="number" data-type="text">${pnuser.number}</span> <span class="veright" data-value="" name="number" data-type="text"></span> </li> <li> <label>手机号:</label> ##<span class="veright" data-value="${pnuser.mobile}" name="mobile" data-type="string">${pnuser.mobile}</span> <span class="veright" data-value="" name="mobile" data-type="string"></span> </li> <li> <label>密码:</label> ##<span class="veright sue pwdtip" data-tip="${account.password}" data-value="${account.password}" data-type="password" name="password">***</span> <span class="veright sue pwdtip" data-tip="" data-value="" data-type="password" name="password">***</span> </li> <li> <label>到期时间:</label> ##<span class="veright sue" data-value="${account.expired}" name="expired" data-type="datetime">${account.expired}</span> <span class="veright sue" data-value="" name="expired" data-type="datetime"></span> </li> <li> <label>终端数:</label> ##<span class="veright sue" data-value="${account.ends}" name="ends" data-type="int">${account.ends}</span> <span class="veright sue" data-value="" name="ends" data-type="int"></span> </li> </ul> </div> </div> <div class="tabbox ns_table"> <div class="toolnav"> <h3>缴费纪录</h3> <div class="toolbox"> <div class="search" id="search"><input type="text" placeholder="搜索" /><button type="button"><i class="searchIcoGray"></i></button></div> </div> </div> <div id="payrecordMemTable"></div> <script src="/static/js/component/payrecord.js"></script> </div> </div> </div> <%block name="jscode"> <script type="text/javascript" src="/static/js/lib/jqueryui.min.js"></script> <script type="text/javascript" src="/static/js/lib/jquery-ui-timepicker-addon.js"></script> </%block>
isc
dockbiz/gnatsd
server/client.go
20486
// Copyright 2012-2015 Apcera Inc. All rights reserved. package server import ( "bufio" "encoding/json" "fmt" "math/rand" "net" "sync" "sync/atomic" "time" "github.com/nats-io/gnatsd/hashmap" "github.com/nats-io/gnatsd/sublist" ) const ( // The size of the bufio reader/writer on top of the socket. defaultBufSize = 32768 // Scratch buffer size for the processMsg() calls. msgScratchSize = 512 msgHeadProto = "MSG " ) // Type of client const ( // CLIENT is an end user. CLIENT = iota // ROUTER is another router in the cluster. ROUTER ) type client struct { mu sync.Mutex typ int cid uint64 lang string opts clientOpts nc net.Conn mpay int ncs string bw *bufio.Writer srv *Server subs *hashmap.HashMap pcd map[*client]struct{} atmr *time.Timer ptmr *time.Timer pout int msgb [msgScratchSize]byte parseState stats route *route } func (c *client) String() (id string) { return c.ncs } func (c *client) GetOpts() *clientOpts { return &c.opts } type subscription struct { client *client subject []byte queue []byte sid []byte nm int64 max int64 } type clientOpts struct { Verbose bool `json:"verbose"` Pedantic bool `json:"pedantic"` SslRequired bool `json:"ssl_required"` Authorization string `json:"auth_token"` Username string `json:"user"` Password string `json:"pass"` Name string `json:"name"` Lang string `json:"lang"` Version string `json:"version"` } var defaultOpts = clientOpts{Verbose: true, Pedantic: true} func init() { rand.Seed(time.Now().UnixNano()) } // Lock should be held func (c *client) initClient() { s := c.srv c.cid = atomic.AddUint64(&s.gcid, 1) c.bw = bufio.NewWriterSize(c.nc, defaultBufSize) c.subs = hashmap.New() // This is a scratch buffer used for processMsg() // The msg header starts with "MSG ", // in bytes that is [77 83 71 32]. c.msgb = [msgScratchSize]byte{77, 83, 71, 32} // This is to track pending clients that have data to be flushed // after we process inbound msgs from our own connection. c.pcd = make(map[*client]struct{}) // snapshot the string version of the connection conn := "-" if ip, ok := c.nc.(*net.TCPConn); ok { addr := ip.RemoteAddr().(*net.TCPAddr) conn = fmt.Sprintf("%s:%d", addr.IP, addr.Port) } switch c.typ { case CLIENT: c.ncs = fmt.Sprintf("%s - cid:%d", conn, c.cid) case ROUTER: c.ncs = fmt.Sprintf("%s - rid:%d", conn, c.cid) } // No clue why, but this stalls and kills performance on Mac (Mavericks). // // if ip, ok := c.nc.(*net.TCPConn); ok { // ip.SetReadBuffer(defaultBufSize) // ip.SetWriteBuffer(2 * defaultBufSize) // } // Set the Ping timer c.setPingTimer() // Spin up the read loop. go c.readLoop() } func (c *client) readLoop() { // Grab the connection off the client, it will be cleared on a close. // We check for that after the loop, but want to avoid a nil dereference c.mu.Lock() nc := c.nc c.mu.Unlock() if nc == nil { return } b := make([]byte, defaultBufSize) for { n, err := nc.Read(b) if err != nil { c.closeConnection() return } if err := c.parse(b[:n]); err != nil { // handled inline if err != ErrMaxPayload && err != ErrAuthorization { c.Errorf("Error reading from client: %s", err.Error()) c.sendErr("Parser Error") c.closeConnection() } return } // Check pending clients for flush. for cp := range c.pcd { // Flush those in the set cp.mu.Lock() if cp.nc != nil { cp.nc.SetWriteDeadline(time.Now().Add(DEFAULT_FLUSH_DEADLINE)) err := cp.bw.Flush() cp.nc.SetWriteDeadline(time.Time{}) if err != nil { c.Debugf("Error flushing: %v", err) cp.mu.Unlock() cp.closeConnection() cp.mu.Lock() } } cp.mu.Unlock() delete(c.pcd, cp) } // Check to see if we got closed, e.g. slow consumer c.mu.Lock() nc := c.nc c.mu.Unlock() if nc == nil { return } } } func (c *client) traceMsg(msg []byte) { if trace == 0 { return } // FIXME(dlc), allow limits to printable payload c.Tracef("->> MSG_PAYLOAD: [%s]", string(msg[:len(msg)-LEN_CR_LF])) } func (c *client) traceInOp(op string, arg []byte) { c.traceOp("->> %s", op, arg) } func (c *client) traceOutOp(op string, arg []byte) { c.traceOp("<<- %s", op, arg) } func (c *client) traceOp(format, op string, arg []byte) { if trace == 0 { return } opa := []interface{}{} if op != "" { opa = append(opa, op) } if arg != nil { opa = append(opa, string(arg)) } c.Tracef(format, opa) } // Process the info message if we are a route. func (c *client) processRouteInfo(info *Info) { c.mu.Lock() if c.route == nil { c.mu.Unlock() return } c.route.remoteID = info.ID // Check to see if we have this remote already registered. // This can happen when both servers have routes to each other. s := c.srv c.mu.Unlock() if s.addRoute(c) { c.Debugf("Registering remote route %q", info.ID) // Send our local subscriptions to this route. s.sendLocalSubsToRoute(c) } else { c.Debugf("Detected duplicate remote route %q", info.ID) c.closeConnection() } } // Process the information messages from Clients and other routes. func (c *client) processInfo(arg []byte) error { info := Info{} if err := json.Unmarshal(arg, &info); err != nil { return err } if c.typ == ROUTER { c.processRouteInfo(&info) } return nil } func (c *client) processErr(errStr string) { c.Errorf("Client error %s", errStr) c.closeConnection() } func (c *client) processConnect(arg []byte) error { c.traceInOp("CONNECT", arg) // This will be resolved regardless before we exit this func, // so we can just clear it here. c.clearAuthTimer() if err := json.Unmarshal(arg, &c.opts); err != nil { return err } if c.srv != nil { // Check for Auth if ok := c.srv.checkAuth(c); !ok { c.authViolation() return ErrAuthorization } } // Grab connection name of remote route. if c.typ == ROUTER && c.route != nil { c.route.remoteID = c.opts.Name } if c.opts.Verbose { c.sendOK() } return nil } func (c *client) authTimeout() { c.sendErr("Authorization Timeout") c.closeConnection() } func (c *client) authViolation() { c.Errorf(ErrAuthorization.Error()) c.sendErr("Authorization Violation") c.closeConnection() } func (c *client) maxPayloadViolation(sz int) { c.Errorf("%s: %d vs %d", ErrMaxPayload.Error(), sz, c.mpay) c.sendErr("Maximum Payload Violation") c.closeConnection() } func (c *client) sendErr(err string) { c.mu.Lock() if c.bw != nil { c.bw.WriteString(fmt.Sprintf("-ERR '%s'\r\n", err)) c.pcd[c] = needFlush } c.mu.Unlock() } func (c *client) sendOK() { c.mu.Lock() c.bw.WriteString("+OK\r\n") c.pcd[c] = needFlush c.mu.Unlock() } func (c *client) processPing() { c.traceInOp("PING", nil) if c.nc == nil { return } c.traceOutOp("PONG", nil) c.mu.Lock() c.bw.WriteString("PONG\r\n") err := c.bw.Flush() if err != nil { c.clearConnection() c.Debugf("Error on Flush, error %s", err.Error()) } c.mu.Unlock() } func (c *client) processPong() { c.traceInOp("PONG", nil) c.mu.Lock() c.pout -= 1 c.mu.Unlock() } func (c *client) processMsgArgs(arg []byte) error { if trace == 1 { c.traceInOp("MSG", arg) } // Unroll splitArgs to avoid runtime/heap issues a := [MAX_MSG_ARGS][]byte{} args := a[:0] start := -1 for i, b := range arg { switch b { case ' ', '\t', '\r', '\n': if start >= 0 { args = append(args, arg[start:i]) start = -1 } default: if start < 0 { start = i } } } if start >= 0 { args = append(args, arg[start:]) } c.pa.subject = args[0] c.pa.sid = args[1] switch len(args) { case 3: c.pa.reply = nil c.pa.szb = args[2] c.pa.size = parseSize(args[2]) case 4: c.pa.reply = args[2] c.pa.szb = args[3] c.pa.size = parseSize(args[3]) default: return fmt.Errorf("processMsgArgs Parse Error: '%s'", arg) } if c.pa.size < 0 { return fmt.Errorf("processMsgArgs Bad or Missing Size: '%s'", arg) } return nil } func (c *client) processPub(arg []byte) error { if trace == 1 { c.traceInOp("PUB", arg) } // Unroll splitArgs to avoid runtime/heap issues a := [MAX_PUB_ARGS][]byte{} args := a[:0] start := -1 for i, b := range arg { switch b { case ' ', '\t', '\r', '\n': if start >= 0 { args = append(args, arg[start:i]) start = -1 } default: if start < 0 { start = i } } } if start >= 0 { args = append(args, arg[start:]) } switch len(args) { case 2: c.pa.subject = args[0] c.pa.reply = nil c.pa.size = parseSize(args[1]) c.pa.szb = args[1] case 3: c.pa.subject = args[0] c.pa.reply = args[1] c.pa.size = parseSize(args[2]) c.pa.szb = args[2] default: return fmt.Errorf("processPub Parse Error: '%s'", arg) } if c.pa.size < 0 { return fmt.Errorf("processPub Bad or Missing Size: '%s'", arg) } if c.mpay > 0 && c.pa.size > c.mpay { c.maxPayloadViolation(c.pa.size) return ErrMaxPayload } if c.opts.Pedantic && !sublist.IsValidLiteralSubject(c.pa.subject) { c.sendErr("Invalid Subject") } return nil } func splitArg(arg []byte) [][]byte { a := [MAX_MSG_ARGS][]byte{} args := a[:0] start := -1 for i, b := range arg { switch b { case ' ', '\t', '\r', '\n': if start >= 0 { args = append(args, arg[start:i]) start = -1 } default: if start < 0 { start = i } } } if start >= 0 { args = append(args, arg[start:]) } return args } func (c *client) processSub(argo []byte) (err error) { c.traceInOp("SUB", argo) // Copy so we do not reference a potentially large buffer arg := make([]byte, len(argo)) copy(arg, argo) args := splitArg(arg) sub := &subscription{client: c} switch len(args) { case 2: sub.subject = args[0] sub.queue = nil sub.sid = args[1] case 3: sub.subject = args[0] sub.queue = args[1] sub.sid = args[2] default: return fmt.Errorf("processSub Parse Error: '%s'", arg) } c.mu.Lock() if c.nc == nil { c.mu.Unlock() return nil } c.subs.Set(sub.sid, sub) if c.srv != nil { err = c.srv.sl.Insert(sub.subject, sub) } shouldForward := c.typ != ROUTER && c.srv != nil c.mu.Unlock() if err != nil { c.sendErr("Invalid Subject") } else if c.opts.Verbose { c.sendOK() } if shouldForward { c.srv.broadcastSubscribe(sub) } return nil } func (c *client) unsubscribe(sub *subscription) { c.mu.Lock() defer c.mu.Unlock() if sub.max > 0 && sub.nm < sub.max { c.Debugf( "Deferring actual UNSUB(%s): %d max, %d received\n", string(sub.subject), sub.max, sub.nm) return } c.traceOp("<-> %s", "DELSUB", sub.sid) c.subs.Remove(sub.sid) if c.srv != nil { c.srv.sl.Remove(sub.subject, sub) } } func (c *client) processUnsub(arg []byte) error { c.traceInOp("UNSUB", arg) args := splitArg(arg) var sid []byte max := -1 switch len(args) { case 1: sid = args[0] case 2: sid = args[0] max = parseSize(args[1]) default: return fmt.Errorf("processUnsub Parse Error: '%s'", arg) } if sub, ok := (c.subs.Get(sid)).(*subscription); ok { if max > 0 { sub.max = int64(max) } else { // Clear it here to override sub.max = 0 } c.unsubscribe(sub) if shouldForward := c.typ != ROUTER && c.srv != nil; shouldForward { c.srv.broadcastUnSubscribe(sub) } } if c.opts.Verbose { c.sendOK() } return nil } func (c *client) msgHeader(mh []byte, sub *subscription) []byte { mh = append(mh, sub.sid...) mh = append(mh, ' ') if c.pa.reply != nil { mh = append(mh, c.pa.reply...) mh = append(mh, ' ') } mh = append(mh, c.pa.szb...) mh = append(mh, "\r\n"...) return mh } // Used to treat maps as efficient set var needFlush = struct{}{} var routeSeen = struct{}{} func (c *client) deliverMsg(sub *subscription, mh, msg []byte) { if sub.client == nil { return } client := sub.client client.mu.Lock() sub.nm++ // Check if we should auto-unsubscribe. if sub.max > 0 { // For routing.. shouldForward := client.typ != ROUTER && client.srv != nil // If we are at the exact number, unsubscribe but // still process the message in hand, otherwise // unsubscribe and drop message on the floor. if sub.nm == sub.max { c.Debugf("Auto-unsubscribe limit of %d reached for sid '%s'\n", sub.max, string(sub.sid)) defer client.unsubscribe(sub) if shouldForward { defer client.srv.broadcastUnSubscribe(sub) } } else if sub.nm > sub.max { c.Debugf("Auto-unsubscribe limit [%d] exceeded\n", sub.max) client.mu.Unlock() client.unsubscribe(sub) if shouldForward { client.srv.broadcastUnSubscribe(sub) } return } } if client.nc == nil { client.mu.Unlock() return } // Update statistics // The msg includes the CR_LF, so pull back out for accounting. msgSize := int64(len(msg) - LEN_CR_LF) client.outMsgs++ client.outBytes += msgSize atomic.AddInt64(&c.srv.outMsgs, 1) atomic.AddInt64(&c.srv.outBytes, msgSize) // Check to see if our writes will cause a flush // in the underlying bufio. If so limit time we // will wait for flush to complete. deadlineSet := false if client.bw.Available() < (len(mh) + len(msg) + len(CR_LF)) { client.nc.SetWriteDeadline(time.Now().Add(DEFAULT_FLUSH_DEADLINE)) deadlineSet = true } // Deliver to the client. _, err := client.bw.Write(mh) if err != nil { goto writeErr } _, err = client.bw.Write(msg) if err != nil { goto writeErr } if trace == 1 { client.traceOutOp(string(mh[:len(mh)-LEN_CR_LF]), nil) } // TODO(dlc) - Do we need this or can we just call always? if deadlineSet { client.nc.SetWriteDeadline(time.Time{}) } client.mu.Unlock() c.pcd[client] = needFlush return writeErr: if deadlineSet { client.nc.SetWriteDeadline(time.Time{}) } client.mu.Unlock() if ne, ok := err.(net.Error); ok && ne.Timeout() { atomic.AddInt64(&client.srv.slowConsumers, 1) client.Noticef("Slow Consumer Detected") client.closeConnection() } else { c.Debugf("Error writing msg: %v", err) } } // processMsg is called to process an inbound msg from a client. func (c *client) processMsg(msg []byte) { // Update statistics // The msg includes the CR_LF, so pull back out for accounting. msgSize := int64(len(msg) - LEN_CR_LF) c.inMsgs++ c.inBytes += msgSize // Snapshot server. srv := c.srv if srv != nil { atomic.AddInt64(&srv.inMsgs, 1) atomic.AddInt64(&srv.inBytes, msgSize) } if trace == 1 { c.traceMsg(msg) } if c.opts.Verbose { c.sendOK() } if srv == nil { return } r := srv.sl.Match(c.pa.subject) if len(r) <= 0 { return } // Scratch buffer.. msgh := c.msgb[:len(msgHeadProto)] // msg header msgh = append(msgh, c.pa.subject...) msgh = append(msgh, ' ') si := len(msgh) var qmap map[string][]*subscription var qsubs []*subscription isRoute := c.typ == ROUTER var rmap map[string]struct{} // If we are a route and we have a queue subscription, deliver direct // since they are sent direct via L2 semantics. If the match is a queue // subscription, we will return from here regardless if we find a sub. if isRoute { if sub, ok := srv.routeSidQueueSubscriber(c.pa.sid); ok { if sub != nil { mh := c.msgHeader(msgh[:si], sub) c.deliverMsg(sub, mh, msg) } return } } // Loop over all subscriptions that match. for _, v := range r { sub := v.(*subscription) // Process queue group subscriptions by gathering them all up // here. We will pick the winners when we are done processing // all of the subscriptions. if sub.queue != nil { // Queue subscriptions handled from routes directly above. if isRoute { continue } // FIXME(dlc), this can be more efficient if qmap == nil { qmap = make(map[string][]*subscription) } qname := string(sub.queue) qsubs = qmap[qname] if qsubs == nil { qsubs = make([]*subscription, 0, 4) } qsubs = append(qsubs, sub) qmap[qname] = qsubs continue } // Process normal, non-queue group subscriptions. // If this is a send to a ROUTER, make sure we only send it // once. The other side will handle the appropriate re-processing. // Also enforce 1-Hop. if sub.client.typ == ROUTER { // Skip if sourced from a ROUTER and going to another ROUTER. // This is 1-Hop semantics for ROUTERs. if isRoute { continue } // Check to see if we have already sent it here. if rmap == nil { rmap = make(map[string]struct{}, srv.numRoutes()) } sub.client.mu.Lock() if sub.client.nc == nil || sub.client.route == nil || sub.client.route.remoteID == "" { c.Debugf("Bad or Missing ROUTER Identity, not processing msg") sub.client.mu.Unlock() continue } if _, ok := rmap[sub.client.route.remoteID]; ok { c.Debugf("Ignoring route, already processed") sub.client.mu.Unlock() continue } rmap[sub.client.route.remoteID] = routeSeen sub.client.mu.Unlock() } mh := c.msgHeader(msgh[:si], sub) c.deliverMsg(sub, mh, msg) } if qmap != nil { for _, qsubs := range qmap { index := rand.Int() % len(qsubs) sub := qsubs[index] mh := c.msgHeader(msgh[:si], sub) c.deliverMsg(sub, mh, msg) } } } func (c *client) processPingTimer() { c.mu.Lock() defer c.mu.Unlock() c.ptmr = nil // Check if we are ready yet.. if _, ok := c.nc.(*net.TCPConn); !ok { return } c.Debugf("%s Ping Timer", c.typeString()) // Check for violation c.pout += 1 if c.pout > c.srv.opts.MaxPingsOut { c.Debugf("Stale Client Connection - Closing") if c.bw != nil { c.bw.WriteString(fmt.Sprintf("-ERR '%s'\r\n", "Stale Connection")) c.bw.Flush() } c.clearConnection() return } c.traceOutOp("PING", nil) // Send PING c.bw.WriteString("PING\r\n") err := c.bw.Flush() if err != nil { c.Debugf("Error on Client Ping Flush, error %s", err) c.clearConnection() } else { // Reset to fire again if all OK. c.setPingTimer() } } func (c *client) setPingTimer() { if c.srv == nil { return } d := c.srv.opts.PingInterval c.ptmr = time.AfterFunc(d, c.processPingTimer) } // Lock should be held func (c *client) clearPingTimer() { if c.ptmr == nil { return } c.ptmr.Stop() c.ptmr = nil } // Lock should be held func (c *client) setAuthTimer(d time.Duration) { c.atmr = time.AfterFunc(d, func() { c.authTimeout() }) } // Lock should be held func (c *client) clearAuthTimer() { if c.atmr == nil { return } c.atmr.Stop() c.atmr = nil } func (c *client) isAuthTimerSet() bool { c.mu.Lock() isSet := c.atmr != nil c.mu.Unlock() return isSet } // Lock should be held func (c *client) clearConnection() { if c.nc == nil { return } c.bw.Flush() c.nc.Close() } func (c *client) typeString() string { switch c.typ { case CLIENT: return "Client" case ROUTER: return "Router" } return "Unknown Type" } func (c *client) closeConnection() { c.mu.Lock() if c.nc == nil { c.mu.Unlock() return } c.Debugf("%s connection closed", c.typeString()) c.clearAuthTimer() c.clearPingTimer() c.clearConnection() c.nc = nil // Snapshot for use. subs := c.subs.All() srv := c.srv c.mu.Unlock() if srv != nil { // Unregister srv.removeClient(c) // Remove clients subscriptions. for _, s := range subs { if sub, ok := s.(*subscription); ok { srv.sl.Remove(sub.subject, sub) // Forward on unsubscribes if we are not // a router ourselves. if c.typ != ROUTER { srv.broadcastUnSubscribe(sub) } } } } // Check for a solicited route. If it was, start up a reconnect unless // we are already connected to the other end. if c.isSolicitedRoute() { srv.mu.Lock() defer srv.mu.Unlock() rid := c.route.remoteID if rid != "" && srv.remotes[rid] != nil { Debugf("Not attempting reconnect for solicited route, already connected to \"%s\"", rid) return } else { Debugf("Attempting reconnect for solicited route \"%s\"", c.route.url) go srv.reConnectToRoute(c.route.url) } } } // Logging functionality scoped to a client or route. func (c *client) Errorf(format string, v ...interface{}) { format = fmt.Sprintf("%s - %s", c, format) Errorf(format, v...) } func (c *client) Debugf(format string, v ...interface{}) { format = fmt.Sprintf("%s - %s", c, format) Debugf(format, v...) } func (c *client) Noticef(format string, v ...interface{}) { format = fmt.Sprintf("%s - %s", c, format) Noticef(format, v...) } func (c *client) Tracef(format string, v ...interface{}) { format = fmt.Sprintf("%s - %s", c, format) Tracef(format, v...) }
mit
georghinkel/ttc2017smartGrids
solutions/eMoflon/rgse.ttc17.metamodels.src/src/gluemodel/CIM/IEC61970/impl/IEC61970CIMVersionImpl.java
5104
/** */ package gluemodel.CIM.IEC61970.impl; import gluemodel.CIM.IEC61970.IEC61970CIMVersion; import gluemodel.CIM.IEC61970.IEC61970Package; import gluemodel.CIM.impl.ElementImpl; import java.util.Date; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.impl.ENotificationImpl; /** * <!-- begin-user-doc --> * An implementation of the model object '<em><b>CIM Version</b></em>'. * <!-- end-user-doc --> * <p> * The following features are implemented: * </p> * <ul> * <li>{@link gluemodel.CIM.IEC61970.impl.IEC61970CIMVersionImpl#getDate <em>Date</em>}</li> * <li>{@link gluemodel.CIM.IEC61970.impl.IEC61970CIMVersionImpl#getVersion <em>Version</em>}</li> * </ul> * * @generated */ public class IEC61970CIMVersionImpl extends ElementImpl implements IEC61970CIMVersion { /** * The default value of the '{@link #getDate() <em>Date</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDate() * @generated * @ordered */ protected static final Date DATE_EDEFAULT = null; /** * The cached value of the '{@link #getDate() <em>Date</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getDate() * @generated * @ordered */ protected Date date = DATE_EDEFAULT; /** * The default value of the '{@link #getVersion() <em>Version</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getVersion() * @generated * @ordered */ protected static final String VERSION_EDEFAULT = null; /** * The cached value of the '{@link #getVersion() <em>Version</em>}' attribute. * <!-- begin-user-doc --> * <!-- end-user-doc --> * @see #getVersion() * @generated * @ordered */ protected String version = VERSION_EDEFAULT; /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ protected IEC61970CIMVersionImpl() { super(); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override protected EClass eStaticClass() { return IEC61970Package.Literals.IEC61970_CIM_VERSION; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public Date getDate() { return date; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setDate(Date newDate) { Date oldDate = date; date = newDate; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, IEC61970Package.IEC61970_CIM_VERSION__DATE, oldDate, date)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public String getVersion() { return version; } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public void setVersion(String newVersion) { String oldVersion = version; version = newVersion; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, IEC61970Package.IEC61970_CIM_VERSION__VERSION, oldVersion, version)); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public Object eGet(int featureID, boolean resolve, boolean coreType) { switch (featureID) { case IEC61970Package.IEC61970_CIM_VERSION__DATE: return getDate(); case IEC61970Package.IEC61970_CIM_VERSION__VERSION: return getVersion(); } return super.eGet(featureID, resolve, coreType); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eSet(int featureID, Object newValue) { switch (featureID) { case IEC61970Package.IEC61970_CIM_VERSION__DATE: setDate((Date)newValue); return; case IEC61970Package.IEC61970_CIM_VERSION__VERSION: setVersion((String)newValue); return; } super.eSet(featureID, newValue); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public void eUnset(int featureID) { switch (featureID) { case IEC61970Package.IEC61970_CIM_VERSION__DATE: setDate(DATE_EDEFAULT); return; case IEC61970Package.IEC61970_CIM_VERSION__VERSION: setVersion(VERSION_EDEFAULT); return; } super.eUnset(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public boolean eIsSet(int featureID) { switch (featureID) { case IEC61970Package.IEC61970_CIM_VERSION__DATE: return DATE_EDEFAULT == null ? date != null : !DATE_EDEFAULT.equals(date); case IEC61970Package.IEC61970_CIM_VERSION__VERSION: return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version); } return super.eIsSet(featureID); } /** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ @Override public String toString() { if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); result.append(" (date: "); result.append(date); result.append(", version: "); result.append(version); result.append(')'); return result.toString(); } } //IEC61970CIMVersionImpl
mit
HockeyWX/HockeySDK-iOSDemo-Swift
Vendor/HockeySDK/Classes/BITTelemetryContext.h
2630
#import "HockeySDKFeatureConfig.h" #if HOCKEYSDK_FEATURE_METRICS #import <Foundation/Foundation.h> #import "BITApplication.h" #import "BITDevice.h" #import "BITInternal.h" #import "BITUser.h" #import "BITSession.h" @class BITPersistence; #import "HockeySDKNullability.h" NS_ASSUME_NONNULL_BEGIN /** * Context object which contains information about the device, user, session etc. */ @interface BITTelemetryContext : NSObject ///----------------------------------------------------------------------------- /// @name Initialisation ///----------------------------------------------------------------------------- /** * The persistence instance used to save/load metadata. */ @property(nonatomic, strong) BITPersistence *persistence; /** * The instrumentation key of the app. */ @property(nonatomic, copy) NSString *appIdentifier; /** * A queue which makes array operations thread safe. */ @property (nonatomic, strong) dispatch_queue_t operationsQueue; /** * The application context. */ @property(nonatomic, strong, readonly) BITApplication *application; /** * The device context. */ @property (nonatomic, strong, readonly)BITDevice *device; /** * The session context. */ @property (nonatomic, strong, readonly)BITSession *session; /** * The user context. */ @property (nonatomic, strong, readonly)BITUser *user; /** * The internal context. */ @property (nonatomic, strong, readonly)BITInternal *internal; /** * Initializes a telemetry context. * * @param appIdentifier the appIdentifier of the app * @param persistence the persistence used to save and load metadata * * @return the telemetry context */ - (instancetype)initWithAppIdentifier:(NSString *)appIdentifier persistence:(BITPersistence *)persistence; ///----------------------------------------------------------------------------- /// @name Helper ///----------------------------------------------------------------------------- /** * A dictionary which holds static tag fields for the purpose of caching */ @property (nonatomic, strong) NSDictionary *tags; /** * Returns context objects as dictionary. * * @return a dictionary containing all context fields */ - (NSDictionary *)contextDictionary; ///----------------------------------------------------------------------------- /// @name Getter/Setter ///----------------------------------------------------------------------------- - (void)setSessionId:(NSString *)sessionId; - (void)setIsFirstSession:(NSString *)isFirstSession; - (void)setIsNewSession:(NSString *)isNewSession; @end NS_ASSUME_NONNULL_END #endif /* HOCKEYSDK_FEATURE_METRICS */
mit
unaio/una
modules/boonex/protean/updates/9.0.9_9.0.10/source/install/config.php
1429
<?php /** * Copyright (c) UNA, Inc - https://una.io * MIT License - https://opensource.org/licenses/MIT * * @defgroup Protean Protean template * @ingroup UnaModules * * @{ */ $aConfig = array( /** * Main Section. */ 'type' => BX_DOL_MODULE_TYPE_TEMPLATE, 'name' => 'bx_protean', 'title' => 'Protean', 'note' => 'Design template', 'version' => '9.0.10', 'vendor' => 'Boonex', 'help_url' => 'http://feed.una.io/?section={module_name}', 'compatible_with' => array( '9.0.0-RC10' ), /** * 'home_dir' and 'home_uri' - should be unique. Don't use spaces in 'home_uri' and the other special chars. */ 'home_dir' => 'boonex/protean/', 'home_uri' => 'protean', 'db_prefix' => 'bx_protean_', 'class_prefix' => 'BxProtean', /** * Category for language keys. */ 'language_category' => 'Boonex Protean Template', /** * Installation/Uninstallation Section. */ 'install' => array( 'execute_sql' => 1, 'update_languages' => 1, 'clear_db_cache' => 1 ), 'uninstall' => array ( 'execute_sql' => 1, 'update_languages' => 1, 'clear_db_cache' => 1 ), 'enable' => array( 'execute_sql' => 1 ), 'disable' => array( 'execute_sql' => 1 ), /** * Dependencies Section */ 'dependencies' => array(), ); /** @} */
mit
daniel-lundin/tern-snabbt
demos/resources/tern-lint/codemirror/addon/lint/tern-lint.js
952
CodeMirror.ternLint = function(cm, updateLinting, options) { function addAnnotation(error, found) { var startLine = error.startLine; var startChar = error.startChar; var endLine = error.endLine; var endChar = error.endChar; var message = error.message; found.push({ from : error.start, to : error.end, message : message }); } var getServer = (typeof options.server == "function") ? options.server : function(cm) {return options.server}; var query = { type : "lint", file : "#0", lineCharPositions : true }; var files = []; files.push({ type : "full", name : "[doc]", text : cm.getValue() }); var doc = { query : query, files : files }; getServer(cm).server.request(doc, function(error, response) { if (error) { updateLinting(cm, []); } else { var messages = response.messages; updateLinting(cm, messages); } }); };
mit
chili-dog-night/site
sql/create.sql
33
CREATE DATABASE chili_dog_night;
mit
DestinyItemManager/DIM
src/app/search/plug-search.ts
982
import { D2ManifestDefinitions } from 'app/destiny2/d2-definitions'; import { PluggableInventoryItemDefinition } from 'app/inventory/item-types'; import { startWordRegexp } from './search-filters/freeform'; export function createPlugSearchPredicate( query: string, language: string, defs: D2ManifestDefinitions ) { if (!query.length) { return (_plug: PluggableInventoryItemDefinition) => true; } const regexp = startWordRegexp(query, language); return (plug: PluggableInventoryItemDefinition) => regexp.test(plug.displayProperties.name) || regexp.test(plug.displayProperties.description) || regexp.test(plug.itemTypeDisplayName) || plug.perks.some((perk) => { const perkDef = defs.SandboxPerk.get(perk.perkHash); return ( perkDef && (regexp.test(perkDef.displayProperties.name) || regexp.test(perkDef.displayProperties.description) || regexp.test(perk.requirementDisplayString)) ); }); }
mit
shairez/angular
packages/animations/browser/test/dsl/animation_spec.ts
48978
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import {animate, animation, AnimationMetadata, AnimationMetadataType, AnimationOptions, AUTO_STYLE, group, keyframes, query, sequence, state, style, transition, trigger, useAnimation, ɵStyleDataMap} from '@angular/animations'; import {Animation} from '../../src/dsl/animation'; import {buildAnimationAst} from '../../src/dsl/animation_ast_builder'; import {AnimationTimelineInstruction} from '../../src/dsl/animation_timeline_instruction'; import {ElementInstructionMap} from '../../src/dsl/element_instruction_map'; import {MockAnimationDriver} from '../../testing'; function createDiv() { return document.createElement('div'); } { describe('Animation', () => { // these tests are only meant to be run within the DOM (for now) if (isNode) return; let rootElement: any; let subElement1: any; let subElement2: any; beforeEach(() => { rootElement = createDiv(); subElement1 = createDiv(); subElement2 = createDiv(); document.body.appendChild(rootElement); rootElement.appendChild(subElement1); rootElement.appendChild(subElement2); }); afterEach(() => { document.body.removeChild(rootElement); }); describe('validation', () => { it('should throw an error if one or more but not all keyframes() styles contain offsets', () => { const steps = animate(1000, keyframes([ style({opacity: 0}), style({opacity: 1, offset: 1}), ])); expect(() => { validateAndThrowAnimationSequence(steps); }) .toThrowError( /Not all style\(\) steps within the declared keyframes\(\) contain offsets/); }); it('should throw an error if not all offsets are between 0 and 1', () => { let steps = animate(1000, keyframes([ style({opacity: 0, offset: -1}), style({opacity: 1, offset: 1}), ])); expect(() => { validateAndThrowAnimationSequence(steps); }).toThrowError(/Please ensure that all keyframe offsets are between 0 and 1/); steps = animate(1000, keyframes([ style({opacity: 0, offset: 0}), style({opacity: 1, offset: 1.1}), ])); expect(() => { validateAndThrowAnimationSequence(steps); }).toThrowError(/Please ensure that all keyframe offsets are between 0 and 1/); }); it('should throw an error if a smaller offset shows up after a bigger one', () => { let steps = animate(1000, keyframes([ style({opacity: 0, offset: 1}), style({opacity: 1, offset: 0}), ])); expect(() => { validateAndThrowAnimationSequence(steps); }).toThrowError(/Please ensure that all keyframe offsets are in order/); }); it('should throw an error if any styles overlap during parallel animations', () => { const steps = group([ sequence([ // 0 -> 2000ms style({opacity: 0}), animate('500ms', style({opacity: .25})), animate('500ms', style({opacity: .5})), animate('500ms', style({opacity: .75})), animate('500ms', style({opacity: 1})) ]), animate('1s 500ms', keyframes([ // 0 -> 1500ms style({width: 0}), style({opacity: 1, width: 1000}), ])) ]); expect(() => { validateAndThrowAnimationSequence(steps); }) .toThrowError( /The CSS property "opacity" that exists between the times of "0ms" and "2000ms" is also being animated in a parallel animation between the times of "0ms" and "1500ms"/); }); it('should not throw an error if animations overlap in different query levels within different transitions', () => { const steps = trigger('myAnimation', [ transition('a => b', group([ query('h1', animate('1s', style({opacity: 0}))), query('h2', animate('1s', style({opacity: 1}))), ])), transition('b => a', group([ query('h1', animate('1s', style({opacity: 0}))), query('h2', animate('1s', style({opacity: 1}))), ])), ]); expect(() => validateAndThrowAnimationSequence(steps)).not.toThrow(); }); it('should not allow triggers to be defined with a prefixed `@` symbol', () => { const steps = trigger('@foo', []); expect(() => validateAndThrowAnimationSequence(steps)) .toThrowError( /animation triggers cannot be prefixed with an `@` sign \(e\.g\. trigger\('@foo', \[...\]\)\)/); }); it('should throw an error if an animation time is invalid', () => { const steps = [animate('500xs', style({opacity: 1}))]; expect(() => { validateAndThrowAnimationSequence(steps); }).toThrowError(/The provided timing value "500xs" is invalid/); const steps2 = [animate('500ms 500ms 500ms ease-out', style({opacity: 1}))]; expect(() => { validateAndThrowAnimationSequence(steps2); }).toThrowError(/The provided timing value "500ms 500ms 500ms ease-out" is invalid/); }); it('should throw if negative durations are used', () => { const steps = [animate(-1000, style({opacity: 1}))]; expect(() => { validateAndThrowAnimationSequence(steps); }).toThrowError(/Duration values below 0 are not allowed for this animation step/); const steps2 = [animate('-1s', style({opacity: 1}))]; expect(() => { validateAndThrowAnimationSequence(steps2); }).toThrowError(/Duration values below 0 are not allowed for this animation step/); }); it('should throw if negative delays are used', () => { const steps = [animate('1s -500ms', style({opacity: 1}))]; expect(() => { validateAndThrowAnimationSequence(steps); }).toThrowError(/Delay values below 0 are not allowed for this animation step/); const steps2 = [animate('1s -0.5s', style({opacity: 1}))]; expect(() => { validateAndThrowAnimationSequence(steps2); }).toThrowError(/Delay values below 0 are not allowed for this animation step/); }); it('should throw if keyframes() is not used inside of animate()', () => { const steps = [keyframes([])]; expect(() => { validateAndThrowAnimationSequence(steps); }).toThrowError(/keyframes\(\) must be placed inside of a call to animate\(\)/); const steps2 = [group([keyframes([])])]; expect(() => { validateAndThrowAnimationSequence(steps2); }).toThrowError(/keyframes\(\) must be placed inside of a call to animate\(\)/); }); it('should throw if dynamic style substitutions are used without defaults within state() definitions', () => { const steps = [ state('final', style({ 'width': '{{ one }}px', 'borderRadius': '{{ two }}px {{ three }}px', })), ]; expect(() => { validateAndThrowAnimationSequence(steps); }) .toThrowError( /state\("final", ...\) must define default values for all the following style substitutions: one, two, three/); const steps2 = [state( 'panfinal', style({ 'color': '{{ greyColor }}', 'borderColor': '1px solid {{ greyColor }}', 'backgroundColor': '{{ redColor }}', }), {params: {redColor: 'maroon'}})]; expect(() => { validateAndThrowAnimationSequence(steps2); }) .toThrowError( /state\("panfinal", ...\) must define default values for all the following style substitutions: greyColor/); }); it('should throw an error if an invalid CSS property is used in the animation', () => { const steps = [animate(1000, style({abc: '500px'}))]; expect(() => { validateAndThrowAnimationSequence(steps); }) .toThrowError( /The provided animation property "abc" is not a supported CSS property for animations/); }); it('should allow a vendor-prefixed property to be used in an animation sequence without throwing an error', () => { const steps = [ style({webkitTransform: 'translateX(0px)'}), animate(1000, style({webkitTransform: 'translateX(100px)'})) ]; expect(() => validateAndThrowAnimationSequence(steps)).not.toThrow(); }); it('should allow for old CSS properties (like transform) to be auto-prefixed by webkit', () => { const steps = [ style({transform: 'translateX(-100px)'}), animate(1000, style({transform: 'translateX(500px)'})) ]; expect(() => validateAndThrowAnimationSequence(steps)).not.toThrow(); }); }); describe('keyframe building', () => { describe('style() / animate()', () => { it('should produce a balanced series of keyframes given a sequence of animate steps', () => { const steps = [ style({width: 0}), animate(1000, style({height: 50})), animate(1000, style({width: 100})), animate(1000, style({height: 150})), animate(1000, style({width: 200})) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players[0].keyframes).toEqual([ new Map<string, string|number>( [['height', AUTO_STYLE], ['width', 0], ['offset', 0]]), new Map<string, string|number>([['height', 50], ['width', 0], ['offset', .25]]), new Map<string, string|number>([['height', 50], ['width', 100], ['offset', .5]]), new Map<string, string|number>([['height', 150], ['width', 100], ['offset', .75]]), new Map<string, string|number>([['height', 150], ['width', 200], ['offset', 1]]), ]); }); it('should fill in missing starting steps when a starting `style()` value is not used', () => { const steps = [animate(1000, style({width: 999}))]; const players = invokeAnimationSequence(rootElement, steps); expect(players[0].keyframes).toEqual([ new Map<string, string|number>([['width', AUTO_STYLE], ['offset', 0]]), new Map<string, string|number>([['width', 999], ['offset', 1]]), ]); }); it('should merge successive style() calls together before an animate() call', () => { const steps = [ style({width: 0}), style({height: 0}), style({width: 200}), style({opacity: 0}), animate(1000, style({width: 100, height: 400, opacity: 1})) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players[0].keyframes).toEqual([ new Map<string, string|number>( [['width', 200], ['height', 0], ['opacity', 0], ['offset', 0]]), new Map<string, string|number>( [['width', 100], ['height', 400], ['opacity', 1], ['offset', 1]]) ]); }); it('should not merge in successive style() calls to the previous animate() keyframe', () => { const steps = [ style({opacity: 0}), animate(1000, style({opacity: .5})), style({opacity: .6}), animate(1000, style({opacity: 1})) ]; const players = invokeAnimationSequence(rootElement, steps); const keyframes = humanizeOffsets(players[0].keyframes, 4); expect(keyframes).toEqual([ new Map<string, string|number>([['opacity', 0], ['offset', 0]]), new Map<string, string|number>([['opacity', .5], ['offset', .4998]]), new Map<string, string|number>([['opacity', .6], ['offset', .5002]]), new Map<string, string|number>([['opacity', 1], ['offset', 1]]), ]); }); it('should support an easing value that uses cubic-bezier(...)', () => { const steps = [ style({opacity: 0}), animate('1s cubic-bezier(.29, .55 ,.53 ,1.53)', style({opacity: 1})) ]; const player = invokeAnimationSequence(rootElement, steps)[0]; const firstKeyframe = player.keyframes[0]; const firstKeyframeEasing = firstKeyframe.get('easing') as string; expect(firstKeyframeEasing.replace(/\s+/g, '')).toEqual('cubic-bezier(.29,.55,.53,1.53)'); }); }); describe('sequence()', () => { it('should not produce extra timelines when multiple sequences are used within each other', () => { const steps = [ style({width: 0}), animate(1000, style({width: 100})), sequence([ animate(1000, style({width: 200})), sequence([ animate(1000, style({width: 300})), ]), ]), animate(1000, style({width: 400})), sequence([ animate(1000, style({width: 500})), ]), ]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(1); const player = players[0]; expect(player.keyframes).toEqual([ new Map<string, string|number>([['width', 0], ['offset', 0]]), new Map<string, string|number>([['width', 100], ['offset', .2]]), new Map<string, string|number>([['width', 200], ['offset', .4]]), new Map<string, string|number>([['width', 300], ['offset', .6]]), new Map<string, string|number>([['width', 400], ['offset', .8]]), new Map<string, string|number>([['width', 500], ['offset', 1]]) ]); }); it('should create a new timeline after a sequence if group() or keyframe() commands are used within', () => { const steps = [ style({width: 100, height: 100}), animate(1000, style({width: 150, height: 150})), sequence([ group([ animate(1000, style({height: 200})), ]), animate(1000, keyframes([style({width: 180}), style({width: 200})])) ]), animate(1000, style({width: 500, height: 500})) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(4); const finalPlayer = players[players.length - 1]; expect(finalPlayer.keyframes).toEqual([ new Map<string, string|number>([['width', 200], ['height', 200], ['offset', 0]]), new Map<string, string|number>([['width', 500], ['height', 500], ['offset', 1]]) ]); }); it('should push the start of a sequence if a delay option is provided', () => { const steps = [ style({width: '0px'}), animate(1000, style({width: '100px'})), sequence( [ animate(1000, style({width: '200px'})), ], {delay: 500}) ]; const players = invokeAnimationSequence(rootElement, steps); const finalPlayer = players[players.length - 1]; expect(finalPlayer.keyframes).toEqual([ new Map<string, string|number>([['width', '100px'], ['offset', 0]]), new Map<string, string|number>([['width', '200px'], ['offset', 1]]), ]); expect(finalPlayer.delay).toEqual(1500); }); it('should allow a float-based delay value to be used', () => { let steps: any[] = [ animate('.75s 0.75s', style({width: '300px'})), ]; let players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(1); let p1 = players.pop()!; expect(p1.duration).toEqual(1500); expect(p1.keyframes).toEqual([ new Map<string, string|number>([['width', '*'], ['offset', 0]]), new Map<string, string|number>([['width', '*'], ['offset', 0.5]]), new Map<string, string|number>([['width', '300px'], ['offset', 1]]), ]); steps = [ style({width: '100px'}), animate('.5s .5s', style({width: '200px'})), ]; players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(1); p1 = players.pop()!; expect(p1.duration).toEqual(1000); expect(p1.keyframes).toEqual([ new Map<string, string|number>([['width', '100px'], ['offset', 0]]), new Map<string, string|number>([['width', '100px'], ['offset', 0.5]]), new Map<string, string|number>([['width', '200px'], ['offset', 1]]), ]); }); }); describe('substitutions', () => { it('should allow params to be substituted even if they are not defaulted in a reusable animation', () => { const myAnimation = animation([ style({left: '{{ start }}'}), animate(1000, style({left: '{{ end }}'})), ]); const steps = [ useAnimation(myAnimation, {params: {start: '0px', end: '100px'}}), ]; const players = invokeAnimationSequence(rootElement, steps, {}); expect(players.length).toEqual(1); const player = players[0]; expect(player.keyframes).toEqual([ new Map<string, string|number>([['left', '0px'], ['offset', 0]]), new Map<string, string|number>([['left', '100px'], ['offset', 1]]), ]); }); it('should substitute in timing values', () => { function makeAnimation(exp: string, options: {[key: string]: any}) { const steps = [style({opacity: 0}), animate(exp, style({opacity: 1}))]; return invokeAnimationSequence(rootElement, steps, options); } let players = makeAnimation('{{ duration }}', buildParams({duration: '1234ms'})); expect(players[0].duration).toEqual(1234); players = makeAnimation('{{ duration }}', buildParams({duration: '9s 2s'})); expect(players[0].duration).toEqual(11000); players = makeAnimation('{{ duration }} 1s', buildParams({duration: '1.5s'})); expect(players[0].duration).toEqual(2500); players = makeAnimation( '{{ duration }} {{ delay }}', buildParams({duration: '1s', delay: '2s'})); expect(players[0].duration).toEqual(3000); }); it('should allow multiple substitutions to occur within the same style value', () => { const steps = [ style({borderRadius: '100px 100px'}), animate(1000, style({borderRadius: '{{ one }}px {{ two }}'})), ]; const players = invokeAnimationSequence(rootElement, steps, buildParams({one: '200', two: '400px'})); expect(players[0].keyframes).toEqual([ new Map<string, string|number>([['offset', 0], ['borderRadius', '100px 100px']]), new Map<string, string|number>([['offset', 1], ['borderRadius', '200px 400px']]) ]); }); it('should substitute in values that are defined as parameters for inner areas of a sequence', () => { const steps = sequence( [ sequence( [ sequence( [ style({height: '{{ x0 }}px'}), animate(1000, style({height: '{{ x2 }}px'})), ], buildParams({x2: '{{ x1 }}3'})), ], buildParams({x1: '{{ x0 }}2'})), ], buildParams({x0: '1'})); const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(1); const [player] = players; expect(player.keyframes).toEqual([ new Map<string, string|number>([['offset', 0], ['height', '1px']]), new Map<string, string|number>([['offset', 1], ['height', '123px']]) ]); }); it('should substitute in values that are defined as parameters for reusable animations', () => { const anim = animation([ style({height: '{{ start }}'}), animate(1000, style({height: '{{ end }}'})), ]); const steps = sequence( [ sequence( [ useAnimation(anim, buildParams({start: '{{ a }}', end: '{{ b }}'})), ], buildParams({a: '100px', b: '200px'})), ], buildParams({a: '0px'})); const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(1); const [player] = players; expect(player.keyframes).toEqual([ new Map<string, string|number>([['offset', 0], ['height', '100px']]), new Map<string, string|number>([['offset', 1], ['height', '200px']]), ]); }); it('should throw an error when an input variable is not provided when invoked and is not a default value', () => { expect(() => invokeAnimationSequence(rootElement, [style({color: '{{ color }}'})])) .toThrowError(/Please provide a value for the animation param color/); expect( () => invokeAnimationSequence( rootElement, [ style({color: '{{ start }}'}), animate('{{ time }}', style({color: '{{ end }}'})), ], buildParams({start: 'blue', end: 'red'}))) .toThrowError(/Please provide a value for the animation param time/); }); }); describe('keyframes()', () => { it('should produce a sub timeline when `keyframes()` is used within a sequence', () => { const steps = [ animate(1000, style({opacity: .5})), animate(1000, style({opacity: 1})), animate( 1000, keyframes([style({height: 0}), style({height: 100}), style({height: 50})])), animate(1000, style({height: 0, opacity: 0})) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(3); const player0 = players[0]; expect(player0.delay).toEqual(0); expect(player0.keyframes).toEqual([ new Map<string, string|number>([['opacity', AUTO_STYLE], ['offset', 0]]), new Map<string, string|number>([['opacity', .5], ['offset', .5]]), new Map<string, string|number>([['opacity', 1], ['offset', 1]]), ]); const subPlayer = players[1]; expect(subPlayer.delay).toEqual(2000); expect(subPlayer.keyframes).toEqual([ new Map<string, string|number>([['height', 0], ['offset', 0]]), new Map<string, string|number>([['height', 100], ['offset', .5]]), new Map<string, string|number>([['height', 50], ['offset', 1]]), ]); const player1 = players[2]; expect(player1.delay).toEqual(3000); expect(player1.keyframes).toEqual([ new Map<string, string|number>([['opacity', 1], ['height', 50], ['offset', 0]]), new Map<string, string|number>([['opacity', 0], ['height', 0], ['offset', 1]]) ]); }); it('should propagate inner keyframe style data to the parent timeline if used afterwards', () => { const steps = [ style({opacity: 0}), animate(1000, style({opacity: .5})), animate(1000, style({opacity: 1})), animate(1000, keyframes([ style({color: 'red'}), style({color: 'blue'}), ])), animate(1000, style({color: 'green', opacity: 0})) ]; const players = invokeAnimationSequence(rootElement, steps); const finalPlayer = players[players.length - 1]; expect(finalPlayer.keyframes).toEqual([ new Map<string, string|number>([['opacity', 1], ['color', 'blue'], ['offset', 0]]), new Map<string, string|number>([['opacity', 0], ['color', 'green'], ['offset', 1]]) ]); }); it('should feed in starting data into inner keyframes if used in an style step beforehand', () => { const steps = [ animate(1000, style({opacity: .5})), animate(1000, keyframes([ style({opacity: .8, offset: .5}), style({opacity: 1, offset: 1}), ])) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(2); const topPlayer = players[0]; expect(topPlayer.keyframes).toEqual([ new Map<string, string|number>([['opacity', AUTO_STYLE], ['offset', 0]]), new Map<string, string|number>([['opacity', .5], ['offset', 1]]) ]); const subPlayer = players[1]; expect(subPlayer.keyframes).toEqual([ new Map<string, string|number>([['opacity', .5], ['offset', 0]]), new Map<string, string|number>([['opacity', .8], ['offset', 0.5]]), new Map<string, string|number>([['opacity', 1], ['offset', 1]]) ]); }); it('should set the easing value as an easing value for the entire timeline', () => { const steps = [ style({opacity: 0}), animate(1000, style({opacity: .5})), animate( '1s ease-out', keyframes([style({opacity: .8, offset: .5}), style({opacity: 1, offset: 1})])) ]; const player = invokeAnimationSequence(rootElement, steps)[1]; expect(player.easing).toEqual('ease-out'); }); it('should combine the starting time + the given delay as the delay value for the animated keyframes', () => { const steps = [ style({opacity: 0}), animate(500, style({opacity: .5})), animate( '1s 2s ease-out', keyframes([style({opacity: .8, offset: .5}), style({opacity: 1, offset: 1})])) ]; const player = invokeAnimationSequence(rootElement, steps)[1]; expect(player.delay).toEqual(2500); }); it('should not leak in additional styles used later on after keyframe styles have already been declared', () => { const steps = [ animate(1000, style({height: '50px'})), animate(2000, keyframes([ style({left: '0', top: '0', offset: 0}), style({left: '40%', top: '50%', offset: .33}), style({left: '60%', top: '80%', offset: .66}), style({left: 'calc(100% - 100px)', top: '100%', offset: 1}), ])), group([animate('2s', style({width: '200px'}))]), animate('2s', style({height: '300px'})), group([animate('2s', style({height: '500px', width: '500px'}))]) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(5); const firstPlayerKeyframes = players[0].keyframes; expect(firstPlayerKeyframes[0].get('width')).toBeFalsy(); expect(firstPlayerKeyframes[1].get('width')).toBeFalsy(); expect(firstPlayerKeyframes[0].get('height')).toEqual(AUTO_STYLE); expect(firstPlayerKeyframes[1].get('height')).toEqual('50px'); const keyframePlayerKeyframes = players[1].keyframes; expect(keyframePlayerKeyframes[0].get('width')).toBeFalsy(); expect(keyframePlayerKeyframes[0].get('height')).toBeFalsy(); const groupPlayerKeyframes = players[2].keyframes; expect(groupPlayerKeyframes[0].get('width')).toEqual(AUTO_STYLE); expect(groupPlayerKeyframes[1].get('width')).toEqual('200px'); expect(groupPlayerKeyframes[0].get('height')).toBeFalsy(); expect(groupPlayerKeyframes[1].get('height')).toBeFalsy(); const secondToFinalAnimatePlayerKeyframes = players[3].keyframes; expect(secondToFinalAnimatePlayerKeyframes[0].get('width')).toBeFalsy(); expect(secondToFinalAnimatePlayerKeyframes[1].get('width')).toBeFalsy(); expect(secondToFinalAnimatePlayerKeyframes[0].get('height')).toEqual('50px'); expect(secondToFinalAnimatePlayerKeyframes[1].get('height')).toEqual('300px'); const finalAnimatePlayerKeyframes = players[4].keyframes; expect(finalAnimatePlayerKeyframes[0].get('width')).toEqual('200px'); expect(finalAnimatePlayerKeyframes[1].get('width')).toEqual('500px'); expect(finalAnimatePlayerKeyframes[0].get('height')).toEqual('300px'); expect(finalAnimatePlayerKeyframes[1].get('height')).toEqual('500px'); }); it('should respect offsets if provided directly within the style data', () => { const steps = animate(1000, keyframes([ style({opacity: 0, offset: 0}), style({opacity: .6, offset: .6}), style({opacity: 1, offset: 1}) ])); const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(1); const player = players[0]; expect(player.keyframes).toEqual([ new Map<string, string|number>([['opacity', 0], ['offset', 0]]), new Map<string, string|number>([['opacity', .6], ['offset', .6]]), new Map<string, string|number>([['opacity', 1], ['offset', 1]]), ]); }); it('should respect offsets if provided directly within the style metadata type', () => { const steps = animate(1000, keyframes([ {type: AnimationMetadataType.Style, offset: 0, styles: {opacity: 0}}, {type: AnimationMetadataType.Style, offset: .4, styles: {opacity: .4}}, {type: AnimationMetadataType.Style, offset: 1, styles: {opacity: 1}}, ])); const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(1); const player = players[0]; expect(player.keyframes).toEqual([ new Map<string, string|number>([['opacity', 0], ['offset', 0]]), new Map<string, string|number>([['opacity', .4], ['offset', .4]]), new Map<string, string|number>([['opacity', 1], ['offset', 1]]), ]); }); }); describe('group()', () => { it('should properly tally style data within a group() for use in a follow-up animate() step', () => { const steps = [ style({width: 0, height: 0}), animate(1000, style({width: 20, height: 50})), group([animate('1s 1s', style({width: 200})), animate('1s', style({height: 500}))]), animate(1000, style({width: 1000, height: 1000})) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(4); const player0 = players[0]; expect(player0.duration).toEqual(1000); expect(player0.keyframes).toEqual([ new Map<string, string|number>([['width', 0], ['height', 0], ['offset', 0]]), new Map<string, string|number>([['width', 20], ['height', 50], ['offset', 1]]) ]); const gPlayer1 = players[1]; expect(gPlayer1.duration).toEqual(2000); expect(gPlayer1.delay).toEqual(1000); expect(gPlayer1.keyframes).toEqual([ new Map<string, string|number>([['width', 20], ['offset', 0]]), new Map<string, string|number>([['width', 20], ['offset', .5]]), new Map<string, string|number>([['width', 200], ['offset', 1]]) ]); const gPlayer2 = players[2]; expect(gPlayer2.duration).toEqual(1000); expect(gPlayer2.delay).toEqual(1000); expect(gPlayer2.keyframes).toEqual([ new Map<string, string|number>([['height', 50], ['offset', 0]]), new Map<string, string|number>([['height', 500], ['offset', 1]]) ]); const player1 = players[3]; expect(player1.duration).toEqual(1000); expect(player1.delay).toEqual(3000); expect(player1.keyframes).toEqual([ new Map<string, string|number>([['width', 200], ['height', 500], ['offset', 0]]), new Map<string, string|number>([['width', 1000], ['height', 1000], ['offset', 1]]) ]); }); it('should support groups with nested sequences', () => { const steps = [group([ sequence([ style({opacity: 0}), animate(1000, style({opacity: 1})), ]), sequence([ style({width: 0}), animate(1000, style({width: 200})), ]) ])]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(2); const gPlayer1 = players[0]; expect(gPlayer1.delay).toEqual(0); expect(gPlayer1.keyframes).toEqual([ new Map<string, string|number>([['opacity', 0], ['offset', 0]]), new Map<string, string|number>([['opacity', 1], ['offset', 1]]), ]); const gPlayer2 = players[1]; expect(gPlayer1.delay).toEqual(0); expect(gPlayer2.keyframes).toEqual([ new Map<string, string|number>([['width', 0], ['offset', 0]]), new Map<string, string|number>([['width', 200], ['offset', 1]]) ]); }); it('should respect delays after group entries', () => { const steps = [ style({width: 0, height: 0}), animate(1000, style({width: 50, height: 50})), group([ animate(1000, style({width: 100})), animate(1000, style({height: 100})), ]), animate('1s 1s', style({height: 200, width: 200})) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(4); const finalPlayer = players[players.length - 1]; expect(finalPlayer.delay).toEqual(2000); expect(finalPlayer.duration).toEqual(2000); expect(finalPlayer.keyframes).toEqual([ new Map<string, string|number>([['width', 100], ['height', 100], ['offset', 0]]), new Map<string, string|number>([['width', 100], ['height', 100], ['offset', .5]]), new Map<string, string|number>([['width', 200], ['height', 200], ['offset', 1]]), ]); }); it('should respect delays after multiple calls to group()', () => { const steps = [ group([animate('2s', style({opacity: 1})), animate('2s', style({width: '100px'}))]), animate(2000, style({width: 0, opacity: 0})), group([animate('2s', style({opacity: 1})), animate('2s', style({width: '200px'}))]), animate(2000, style({width: 0, opacity: 0})) ]; const players = invokeAnimationSequence(rootElement, steps); const middlePlayer = players[2]; expect(middlePlayer.delay).toEqual(2000); expect(middlePlayer.duration).toEqual(2000); const finalPlayer = players[players.length - 1]; expect(finalPlayer.delay).toEqual(6000); expect(finalPlayer.duration).toEqual(2000); }); it('should push the start of a group if a delay option is provided', () => { const steps = [ style({width: '0px', height: '0px'}), animate(1500, style({width: '100px', height: '100px'})), group( [ animate(1000, style({width: '200px'})), animate(2000, style({height: '200px'})), ], {delay: 300}) ]; const players = invokeAnimationSequence(rootElement, steps); const finalWidthPlayer = players[players.length - 2]; const finalHeightPlayer = players[players.length - 1]; expect(finalWidthPlayer.delay).toEqual(1800); expect(finalWidthPlayer.keyframes).toEqual([ new Map<string, string|number>([['width', '100px'], ['offset', 0]]), new Map<string, string|number>([['width', '200px'], ['offset', 1]]), ]); expect(finalHeightPlayer.delay).toEqual(1800); expect(finalHeightPlayer.keyframes).toEqual([ new Map<string, string|number>([['height', '100px'], ['offset', 0]]), new Map<string, string|number>([['height', '200px'], ['offset', 1]]), ]); }); }); describe('query()', () => { it('should delay the query operation if a delay option is provided', () => { const steps = [ style({opacity: 0}), animate(1000, style({opacity: 1})), query( 'div', [ style({width: 0}), animate(500, style({width: 200})), ], {delay: 200}) ]; const players = invokeAnimationSequence(rootElement, steps); const finalPlayer = players[players.length - 1]; expect(finalPlayer.delay).toEqual(1200); }); it('should throw an error when an animation query returns zero elements', () => { const steps = [query('somethingFake', [style({opacity: 0}), animate(1000, style({opacity: 1}))])]; expect(() => { invokeAnimationSequence(rootElement, steps); }) .toThrowError( /`query\("somethingFake"\)` returned zero elements\. \(Use `query\("somethingFake", \{ optional: true \}\)` if you wish to allow this\.\)/); }); it('should allow a query to be skipped if it is set as optional and returns zero elements', () => { const steps = [query( 'somethingFake', [style({opacity: 0}), animate(1000, style({opacity: 1}))], {optional: true})]; expect(() => { invokeAnimationSequence(rootElement, steps); }).not.toThrow(); const steps2 = [query( 'fakeSomethings', [style({opacity: 0}), animate(1000, style({opacity: 1}))], {optional: true})]; expect(() => { invokeAnimationSequence(rootElement, steps2); }).not.toThrow(); }); it('should delay the query operation if a delay option is provided', () => { const steps = [ style({opacity: 0}), animate(1300, style({opacity: 1})), query( 'div', [ style({width: 0}), animate(500, style({width: 200})), ], {delay: 300}) ]; const players = invokeAnimationSequence(rootElement, steps); const fp1 = players[players.length - 2]; const fp2 = players[players.length - 1]; expect(fp1.delay).toEqual(1600); expect(fp2.delay).toEqual(1600); }); }); describe('timing values', () => { it('should properly combine an easing value with a delay into a set of three keyframes', () => { const steps: AnimationMetadata[] = [style({opacity: 0}), animate('3s 1s ease-out', style({opacity: 1}))]; const player = invokeAnimationSequence(rootElement, steps)[0]; expect(player.keyframes).toEqual([ new Map<string, string|number>([['opacity', 0], ['offset', 0]]), new Map<string, string|number>( [['opacity', 0], ['offset', .25], ['easing', 'ease-out']]), new Map<string, string|number>([['opacity', 1], ['offset', 1]]) ]); }); it('should allow easing values to exist for each animate() step', () => { const steps: AnimationMetadata[] = [ style({width: 0}), animate('1s linear', style({width: 10})), animate('2s ease-out', style({width: 20})), animate('1s ease-in', style({width: 30})) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players.length).toEqual(1); const player = players[0]; expect(player.keyframes).toEqual([ new Map<string, string|number>([['width', 0], ['offset', 0], ['easing', 'linear']]), new Map<string, string|number>( [['width', 10], ['offset', .25], ['easing', 'ease-out']]), new Map<string, string|number>([['width', 20], ['offset', .75], ['easing', 'ease-in']]), new Map<string, string|number>([['width', 30], ['offset', 1]]) ]); }); it('should produce a top-level timeline only for the duration that is set as before a group kicks in', () => { const steps: AnimationMetadata[] = [ style({width: 0, height: 0, opacity: 0}), animate('1s', style({width: 100, height: 100, opacity: .2})), group([ animate('500ms 1s', style({width: 500})), animate('1s', style({height: 500})), sequence([ animate(500, style({opacity: .5})), animate(500, style({opacity: .6})), animate(500, style({opacity: .7})), animate(500, style({opacity: 1})), ]) ]) ]; const player = invokeAnimationSequence(rootElement, steps)[0]; expect(player.duration).toEqual(1000); expect(player.delay).toEqual(0); }); it('should offset group() and keyframe() timelines with a delay which is the current time of the previous player when called', () => { const steps: AnimationMetadata[] = [ style({width: 0, height: 0}), animate('1500ms linear', style({width: 10, height: 10})), group([ animate(1000, style({width: 500, height: 500})), animate(2000, style({width: 500, height: 500})) ]), animate(1000, keyframes([ style({width: 200}), style({width: 500}), ])) ]; const players = invokeAnimationSequence(rootElement, steps); expect(players[0].delay).toEqual(0); // top-level animation expect(players[1].delay).toEqual(1500); // first entry in group() expect(players[2].delay).toEqual(1500); // second entry in group() expect(players[3].delay).toEqual(3500); // animate(...keyframes()) }); }); describe('state based data', () => { it('should create an empty animation if there are zero animation steps', () => { const steps: AnimationMetadata[] = []; const fromStyles: Array<ɵStyleDataMap> = [new Map<string, string|number>([['background', 'blue'], ['height', 100]])]; const toStyles: Array<ɵStyleDataMap> = [new Map<string, string|number>([['background', 'red']])]; const player = invokeAnimationSequence(rootElement, steps, {}, fromStyles, toStyles)[0]; expect(player.duration).toEqual(0); expect(player.keyframes).toEqual([]); }); it('should produce an animation from start to end between the to and from styles if there are animate steps in between', () => { const steps: AnimationMetadata[] = [animate(1000)]; const fromStyles: Array<ɵStyleDataMap> = [new Map<string, string|number>([['background', 'blue'], ['height', 100]])]; const toStyles: Array<ɵStyleDataMap> = [new Map<string, string|number>([['background', 'red']])]; const players = invokeAnimationSequence(rootElement, steps, {}, fromStyles, toStyles); expect(players[0].keyframes).toEqual([ new Map<string, string|number>( [['background', 'blue'], ['height', 100], ['offset', 0]]), new Map<string, string|number>( [['background', 'red'], ['height', AUTO_STYLE], ['offset', 1]]) ]); }); it('should produce an animation from start to end between the to and from styles if there are animate steps in between with an easing value', () => { const steps: AnimationMetadata[] = [animate('1s ease-out')]; const fromStyles: Array<ɵStyleDataMap> = [new Map<string, string|number>([['background', 'blue']])]; const toStyles: Array<ɵStyleDataMap> = [new Map<string, string|number>([['background', 'red']])]; const players = invokeAnimationSequence(rootElement, steps, {}, fromStyles, toStyles); expect(players[0].keyframes).toEqual([ new Map<string, string|number>( [['background', 'blue'], ['offset', 0], ['easing', 'ease-out']]), new Map<string, string|number>([['background', 'red'], ['offset', 1]]) ]); }); }); }); }); } function humanizeOffsets( keyframes: Array<ɵStyleDataMap>, digits: number = 3): Array<ɵStyleDataMap> { return keyframes.map(keyframe => { keyframe.set('offset', Number(parseFloat(<any>keyframe.get('offset')).toFixed(digits))); return keyframe; }); } function invokeAnimationSequence( element: any, steps: AnimationMetadata|AnimationMetadata[], locals: {[key: string]: any} = {}, startingStyles: Array<ɵStyleDataMap> = [], destinationStyles: Array<ɵStyleDataMap> = [], subInstructions?: ElementInstructionMap): AnimationTimelineInstruction[] { const driver = new MockAnimationDriver(); return new Animation(driver, steps) .buildTimelines(element, startingStyles, destinationStyles, locals, subInstructions); } function validateAndThrowAnimationSequence(steps: AnimationMetadata|AnimationMetadata[]) { const driver = new MockAnimationDriver(); const errors: string[] = []; const ast = buildAnimationAst(driver, steps, errors); if (errors.length) { throw new Error(errors.join('\n')); } } function buildParams(params: {[name: string]: any}): AnimationOptions { return <AnimationOptions>{params}; }
mit
rwang23/LintCodeBook
Math/Reverse-Integer.md
1151
##Reverse Integer Total Accepted: 125296 Total Submissions: 531450 Difficulty: Easy Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Have you thought about this? Here are some good questions to ask before coding. Bonus points for you if you have already thought through this! If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100. Did you notice that the reversed integer might overflow? Assume the input is a 32-bit integer, then the reverse of 1000000003 overflows. How should you handle such cases? For the purpose of this problem, assume that your function returns 0 when the reversed integer overflows. ####思路 - 用long来处理了overflow ```java public class Solution { public int reverse(int x) { return x >= 0 ? reverseNum(x) : -reverseNum(-x); } public int reverseNum(int x) { long sum = 0; while (x >= 1) { sum *= 10; int a = x % 10; x /= 10; sum += a; } return sum > Integer.MAX_VALUE ? 0 : (int) sum; } } ```
mit
linmuxi/ttw
src/com/phly/ttw/manage/supplier/action/SupplierOrderAction.java
1854
/* * Copyright 2015 the original author or phly. * 未经正式书面同意,其他任何个人、团体不得使用、复制、修改或发布本软件. */ package com.phly.ttw.manage.supplier.action; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.directwebremoting.annotations.RemoteProxy; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.phly.common.base.action.BaseAction; import com.phly.common.exceptionhandler.annotation.ExceptionMessage; import com.phly.ttw.manage.order.facade.OrderFacade; import com.phly.ttw.manage.order.model.OrderVO; /** * 订单Action类(供应商使用) * * @author LGP */ @Controller @RemoteProxy public class SupplierOrderAction extends BaseAction { @Resource private OrderFacade orderFacade; /** * 查询订单列表 * * @param orderVO * @return 订单集合 */ @ExceptionMessage("查询订单列表失败,请联系管理员") @RequestMapping("/page/ttw/manage/supplier/order") @ResponseBody public ModelMap queryOrderList(HttpServletRequest request, OrderVO orderVO) { String method = request.getParameter("m"); String[] orders = null; if (method.equals("finish")) { orders = new String[1]; orders[0] = "7"; } if (method.equals("unfinish")) { orders = new String[5]; orders[0] = "2"; orders[1] = "3"; orders[2] = "4"; orders[3] = "5"; orders[4] = "6"; } if (method.equals("all")) { orders = new String[6]; orders[0] = "2"; orders[1] = "3"; orders[2] = "4"; orders[3] = "5"; orders[4] = "6"; orders[4] = "7"; } orderVO.setInOrderStatus(orders); return this.orderFacade.queryOrderList(orderVO); } }
mit
gulkodmitriy/gulkodmitriy.github.io
docs/src_utils_LinkedList.js.html
47194
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Phaser Source: src/utils/LinkedList.js</title> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/default.css"> <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css"> <link type="text/css" rel="stylesheet" href="styles/site.cerulean.css"> </head> <body> <div class="container-fluid"> <div class="navbar navbar-fixed-top navbar-inverse"> <div style="position: absolute; width: 143px; height: 31px; right: 10px; top: 10px; z-index: 1050"><a href="http://phaser.io"><img src="img/phaser.png" border="0" /></a></div> <div class="navbar-inner"> <a class="brand" href="index.html">Phaser API</a> <ul class="nav"> <li class="dropdown"> <a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-0"> <a href="Phaser.html">Phaser</a> </li> <li class="class-depth-0"> <a href="PIXI.html">PIXI</a> </li> </ul> </li> <li class="dropdown"> <a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-0"> <a href="EarCut.html">EarCut</a> </li> <li class="class-depth-0"> <a href="Event.html">Event</a> </li> <li class="class-depth-0"> <a href="EventTarget.html">EventTarget</a> </li> <li class="class-depth-1"> <a href="Phaser.Animation.html">Animation</a> </li> <li class="class-depth-1"> <a href="Phaser.AnimationManager.html">AnimationManager</a> </li> <li class="class-depth-1"> <a href="Phaser.AnimationParser.html">AnimationParser</a> </li> <li class="class-depth-1"> <a href="Phaser.ArraySet.html">ArraySet</a> </li> <li class="class-depth-1"> <a href="Phaser.ArrayUtils.html">ArrayUtils</a> </li> <li class="class-depth-1"> <a href="Phaser.AudioSprite.html">AudioSprite</a> </li> <li class="class-depth-1"> <a href="Phaser.BitmapData.html">BitmapData</a> </li> <li class="class-depth-1"> <a href="Phaser.BitmapText.html">BitmapText</a> </li> <li class="class-depth-1"> <a href="Phaser.Bullet.html">Bullet</a> </li> <li class="class-depth-1"> <a href="Phaser.Button.html">Button</a> </li> <li class="class-depth-1"> <a href="Phaser.Cache.html">Cache</a> </li> <li class="class-depth-1"> <a href="Phaser.Camera.html">Camera</a> </li> <li class="class-depth-1"> <a href="Phaser.Canvas.html">Canvas</a> </li> <li class="class-depth-1"> <a href="Phaser.CanvasPool.html">CanvasPool</a> </li> <li class="class-depth-1"> <a href="Phaser.Circle.html">Circle</a> </li> <li class="class-depth-1"> <a href="Phaser.Color.html">Color</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Angle.html">Angle</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Animation.html">Animation</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.AutoCull.html">AutoCull</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Bounds.html">Bounds</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.BringToTop.html">BringToTop</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Core.html">Core</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Crop.html">Crop</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Delta.html">Delta</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Destroy.html">Destroy</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.FixedToCamera.html">FixedToCamera</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Health.html">Health</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.InCamera.html">InCamera</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.InputEnabled.html">InputEnabled</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.InWorld.html">InWorld</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.LifeSpan.html">LifeSpan</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.LoadTexture.html">LoadTexture</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Overlap.html">Overlap</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.PhysicsBody.html">PhysicsBody</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Reset.html">Reset</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.ScaleMinMax.html">ScaleMinMax</a> </li> <li class="class-depth-2"> <a href="Phaser.Component.Smoothed.html">Smoothed</a> </li> <li class="class-depth-1"> <a href="Phaser.Create.html">Create</a> </li> <li class="class-depth-1"> <a href="Phaser.Creature.html">Creature</a> </li> <li class="class-depth-1"> <a href="Phaser.Device.html">Device</a> </li> <li class="class-depth-1"> <a href="Phaser.DeviceButton.html">DeviceButton</a> </li> <li class="class-depth-1"> <a href="Phaser.DOM.html">DOM</a> </li> <li class="class-depth-1"> <a href="Phaser.Easing.html">Easing</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Back.html">Back</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Bounce.html">Bounce</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Circular.html">Circular</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Cubic.html">Cubic</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Elastic.html">Elastic</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Exponential.html">Exponential</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Linear.html">Linear</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Quadratic.html">Quadratic</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Quartic.html">Quartic</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Quintic.html">Quintic</a> </li> <li class="class-depth-2"> <a href="Phaser.Easing.Sinusoidal.html">Sinusoidal</a> </li> <li class="class-depth-1"> <a href="Phaser.Ellipse.html">Ellipse</a> </li> <li class="class-depth-1"> <a href="Phaser.Events.html">Events</a> </li> <li class="class-depth-1"> <a href="Phaser.Filter.html">Filter</a> </li> <li class="class-depth-1"> <a href="Phaser.FlexGrid.html">FlexGrid</a> </li> <li class="class-depth-1"> <a href="Phaser.FlexLayer.html">FlexLayer</a> </li> <li class="class-depth-1"> <a href="Phaser.Frame.html">Frame</a> </li> <li class="class-depth-1"> <a href="Phaser.FrameData.html">FrameData</a> </li> <li class="class-depth-1"> <a href="Phaser.Game.html">Game</a> </li> <li class="class-depth-1"> <a href="Phaser.GameObjectCreator.html">GameObjectCreator</a> </li> <li class="class-depth-1"> <a href="Phaser.GameObjectFactory.html">GameObjectFactory</a> </li> <li class="class-depth-1"> <a href="Phaser.Gamepad.html">Gamepad</a> </li> <li class="class-depth-1"> <a href="Phaser.Graphics.html">Graphics</a> </li> <li class="class-depth-1"> <a href="Phaser.Group.html">Group</a> </li> <li class="class-depth-1"> <a href="Phaser.Hermite.html">Hermite</a> </li> <li class="class-depth-1"> <a href="Phaser.Image.html">Image</a> </li> <li class="class-depth-1"> <a href="Phaser.ImageCollection.html">ImageCollection</a> </li> <li class="class-depth-1"> <a href="Phaser.Input.html">Input</a> </li> <li class="class-depth-1"> <a href="Phaser.InputHandler.html">InputHandler</a> </li> <li class="class-depth-1"> <a href="Phaser.Key.html">Key</a> </li> <li class="class-depth-1"> <a href="Phaser.Keyboard.html">Keyboard</a> </li> <li class="class-depth-1"> <a href="Phaser.KeyCode.html">KeyCode</a> </li> <li class="class-depth-1"> <a href="Phaser.Line.html">Line</a> </li> <li class="class-depth-1"> <a href="Phaser.LinkedList.html">LinkedList</a> </li> <li class="class-depth-1"> <a href="Phaser.Loader.html">Loader</a> </li> <li class="class-depth-1"> <a href="Phaser.LoaderParser.html">LoaderParser</a> </li> <li class="class-depth-1"> <a href="Phaser.Math.html">Math</a> </li> <li class="class-depth-1"> <a href="Phaser.Matrix.html">Matrix</a> </li> <li class="class-depth-1"> <a href="Phaser.Mouse.html">Mouse</a> </li> <li class="class-depth-1"> <a href="Phaser.MSPointer.html">MSPointer</a> </li> <li class="class-depth-1"> <a href="Phaser.Net.html">Net</a> </li> <li class="class-depth-1"> <a href="Phaser.Particle.html">Particle</a> </li> <li class="class-depth-1"> <a href="Phaser.Particles.html">Particles</a> </li> <li class="class-depth-2"> <a href="Phaser.Particles.Arcade.html">Arcade</a> </li> <li class="class-depth-3"> <a href="Phaser.Particles.Arcade.Emitter.html">Emitter</a> </li> <li class="class-depth-1"> <a href="Phaser.Path.html">Path</a> </li> <li class="class-depth-1"> <a href="Phaser.PathFollower.html">PathFollower</a> </li> <li class="class-depth-1"> <a href="Phaser.PathPoint.html">PathPoint</a> </li> <li class="class-depth-1"> <a href="Phaser.Physics.html">Physics</a> </li> <li class="class-depth-2"> <a href="Phaser.Physics.Arcade.html">Arcade</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.Arcade.Body.html">Body</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.Arcade.TilemapCollision.html">TilemapCollision</a> </li> <li class="class-depth-2"> <a href="Phaser.Physics.Ninja.html">Ninja</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.Ninja.AABB.html">AABB</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.Ninja.Body.html">Body</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.Ninja.Circle.html">Circle</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.Ninja.Tile.html">Tile</a> </li> <li class="class-depth-2"> <a href="Phaser.Physics.P2.html">P2</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.Body.html">Body</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.BodyDebug.html">BodyDebug</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.DistanceConstraint.html">DistanceConstraint</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.FixtureList.html">FixtureList</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.GearConstraint.html">GearConstraint</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.InversePointProxy.html">InversePointProxy</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.LockConstraint.html">LockConstraint</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.Material.html">Material</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.PointProxy.html">PointProxy</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.PrismaticConstraint.html">PrismaticConstraint</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.RevoluteConstraint.html">RevoluteConstraint</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.RotationalSpring.html">RotationalSpring</a> </li> <li class="class-depth-3"> <a href="Phaser.Physics.P2.Spring.html">Spring</a> </li> <li class="class-depth-1"> <a href="Phaser.Plugin.html">Plugin</a> </li> <li class="class-depth-2"> <a href="Phaser.Plugin.PathManager.html">PathManager</a> </li> <li class="class-depth-1"> <a href="Phaser.PluginManager.html">PluginManager</a> </li> <li class="class-depth-1"> <a href="Phaser.Point.html">Point</a> </li> <li class="class-depth-1"> <a href="Phaser.Pointer.html">Pointer</a> </li> <li class="class-depth-1"> <a href="Phaser.PointerMode.html">PointerMode</a> </li> <li class="class-depth-1"> <a href="Phaser.Polygon.html">Polygon</a> </li> <li class="class-depth-1"> <a href="Phaser.QuadTree.html">QuadTree</a> </li> <li class="class-depth-1"> <a href="Phaser.RandomDataGenerator.html">RandomDataGenerator</a> </li> <li class="class-depth-1"> <a href="Phaser.Rectangle.html">Rectangle</a> </li> <li class="class-depth-1"> <a href="Phaser.RenderTexture.html">RenderTexture</a> </li> <li class="class-depth-1"> <a href="Phaser.RequestAnimationFrame.html">RequestAnimationFrame</a> </li> <li class="class-depth-1"> <a href="Phaser.RetroFont.html">RetroFont</a> </li> <li class="class-depth-1"> <a href="Phaser.Rope.html">Rope</a> </li> <li class="class-depth-1"> <a href="Phaser.RoundedRectangle.html">RoundedRectangle</a> </li> <li class="class-depth-1"> <a href="Phaser.ScaleManager.html">ScaleManager</a> </li> <li class="class-depth-1"> <a href="Phaser.Signal.html">Signal</a> </li> <li class="class-depth-1"> <a href="Phaser.SignalBinding.html">SignalBinding</a> </li> <li class="class-depth-1"> <a href="Phaser.SinglePad.html">SinglePad</a> </li> <li class="class-depth-1"> <a href="Phaser.Sound.html">Sound</a> </li> <li class="class-depth-1"> <a href="Phaser.SoundManager.html">SoundManager</a> </li> <li class="class-depth-1"> <a href="Phaser.Sprite.html">Sprite</a> </li> <li class="class-depth-1"> <a href="Phaser.SpriteBatch.html">SpriteBatch</a> </li> <li class="class-depth-1"> <a href="Phaser.Stage.html">Stage</a> </li> <li class="class-depth-1"> <a href="Phaser.State.html">State</a> </li> <li class="class-depth-1"> <a href="Phaser.StateManager.html">StateManager</a> </li> <li class="class-depth-1"> <a href="Phaser.Text.html">Text</a> </li> <li class="class-depth-1"> <a href="Phaser.Tile.html">Tile</a> </li> <li class="class-depth-1"> <a href="Phaser.Tilemap.html">Tilemap</a> </li> <li class="class-depth-1"> <a href="Phaser.TilemapLayer.html">TilemapLayer</a> </li> <li class="class-depth-1"> <a href="Phaser.TilemapParser.html">TilemapParser</a> </li> <li class="class-depth-1"> <a href="Phaser.Tileset.html">Tileset</a> </li> <li class="class-depth-1"> <a href="Phaser.TileSprite.html">TileSprite</a> </li> <li class="class-depth-1"> <a href="Phaser.Time.html">Time</a> </li> <li class="class-depth-1"> <a href="Phaser.Timer.html">Timer</a> </li> <li class="class-depth-1"> <a href="Phaser.TimerEvent.html">TimerEvent</a> </li> <li class="class-depth-1"> <a href="Phaser.Touch.html">Touch</a> </li> <li class="class-depth-1"> <a href="Phaser.Tween.html">Tween</a> </li> <li class="class-depth-1"> <a href="Phaser.TweenData.html">TweenData</a> </li> <li class="class-depth-1"> <a href="Phaser.TweenManager.html">TweenManager</a> </li> <li class="class-depth-1"> <a href="Phaser.Utils.html">Utils</a> </li> <li class="class-depth-2"> <a href="Phaser.Utils.Debug.html">Debug</a> </li> <li class="class-depth-1"> <a href="Phaser.Video.html">Video</a> </li> <li class="class-depth-1"> <a href="Phaser.Weapon.html">Weapon</a> </li> <li class="class-depth-1"> <a href="Phaser.World.html">World</a> </li> <li class="class-depth-1"> <a href="PIXI.BaseTexture.html">BaseTexture</a> </li> <li class="class-depth-1"> <a href="PIXI.CanvasBuffer.html">CanvasBuffer</a> </li> <li class="class-depth-1"> <a href="PIXI.CanvasGraphics.html">CanvasGraphics</a> </li> <li class="class-depth-1"> <a href="PIXI.CanvasMaskManager.html">CanvasMaskManager</a> </li> <li class="class-depth-1"> <a href="PIXI.CanvasRenderer.html">CanvasRenderer</a> </li> <li class="class-depth-1"> <a href="PIXI.CanvasTinter.html">CanvasTinter</a> </li> <li class="class-depth-1"> <a href="PIXI.ComplexPrimitiveShader.html">ComplexPrimitiveShader</a> </li> <li class="class-depth-1"> <a href="PIXI.DisplayObject.html">DisplayObject</a> </li> <li class="class-depth-1"> <a href="PIXI.DisplayObjectContainer.html">DisplayObjectContainer</a> </li> <li class="class-depth-1"> <a href="PIXI.FilterTexture.html">FilterTexture</a> </li> <li class="class-depth-2"> <a href="PIXI.Phaser.GraphicsData.html">Phaser.GraphicsData</a> </li> <li class="class-depth-1"> <a href="PIXI.PIXI.html">PIXI</a> </li> <li class="class-depth-1"> <a href="PIXI.PixiFastShader.html">PixiFastShader</a> </li> <li class="class-depth-1"> <a href="PIXI.PixiShader.html">PixiShader</a> </li> <li class="class-depth-1"> <a href="PIXI.PrimitiveShader.html">PrimitiveShader</a> </li> <li class="class-depth-1"> <a href="PIXI.Sprite.html">Sprite</a> </li> <li class="class-depth-1"> <a href="PIXI.StripShader.html">StripShader</a> </li> <li class="class-depth-1"> <a href="PIXI.Texture.html">Texture</a> </li> <li class="class-depth-1"> <a href="PIXI.WebGLBlendModeManager.html">WebGLBlendModeManager</a> </li> <li class="class-depth-1"> <a href="PIXI.WebGLFastSpriteBatch.html">WebGLFastSpriteBatch</a> </li> <li class="class-depth-1"> <a href="PIXI.WebGLFilterManager.html">WebGLFilterManager</a> </li> <li class="class-depth-1"> <a href="PIXI.WebGLRenderer.html">WebGLRenderer</a> </li> </ul> </li> <li class="dropdown"> <a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-0"> <a href="global.html#ANGLE_DOWN">ANGLE_DOWN</a> </li> <li class="class-depth-0"> <a href="global.html#ANGLE_LEFT">ANGLE_LEFT</a> </li> <li class="class-depth-0"> <a href="global.html#ANGLE_NORTH_EAST">ANGLE_NORTH_EAST</a> </li> <li class="class-depth-0"> <a href="global.html#ANGLE_NORTH_WEST">ANGLE_NORTH_WEST</a> </li> <li class="class-depth-0"> <a href="global.html#ANGLE_RIGHT">ANGLE_RIGHT</a> </li> <li class="class-depth-0"> <a href="global.html#ANGLE_SOUTH_EAST">ANGLE_SOUTH_EAST</a> </li> <li class="class-depth-0"> <a href="global.html#ANGLE_SOUTH_WEST">ANGLE_SOUTH_WEST</a> </li> <li class="class-depth-0"> <a href="global.html#ANGLE_UP">ANGLE_UP</a> </li> <li class="class-depth-0"> <a href="global.html#arc">arc</a> </li> <li class="class-depth-0"> <a href="global.html#AUTO">AUTO</a> </li> <li class="class-depth-0"> <a href="global.html#beginFill">beginFill</a> </li> <li class="class-depth-0"> <a href="global.html#bezierCurveTo">bezierCurveTo</a> </li> <li class="class-depth-0"> <a href="global.html#BITMAPDATA">BITMAPDATA</a> </li> <li class="class-depth-0"> <a href="global.html#BITMAPTEXT">BITMAPTEXT</a> </li> <li class="class-depth-0"> <a href="global.html#blendModes">blendModes</a> </li> <li class="class-depth-0"> <a href="global.html#BOTTOM_CENTER">BOTTOM_CENTER</a> </li> <li class="class-depth-0"> <a href="global.html#BOTTOM_LEFT">BOTTOM_LEFT</a> </li> <li class="class-depth-0"> <a href="global.html#BOTTOM_RIGHT">BOTTOM_RIGHT</a> </li> <li class="class-depth-0"> <a href="global.html#BUTTON">BUTTON</a> </li> <li class="class-depth-0"> <a href="global.html#CANVAS">CANVAS</a> </li> <li class="class-depth-0"> <a href="global.html#CANVAS_FILTER">CANVAS_FILTER</a> </li> <li class="class-depth-0"> <a href="global.html#CENTER">CENTER</a> </li> <li class="class-depth-0"> <a href="global.html#CIRCLE">CIRCLE</a> </li> <li class="class-depth-0"> <a href="global.html#clear">clear</a> </li> <li class="class-depth-0"> <a href="global.html#CREATURE">CREATURE</a> </li> <li class="class-depth-0"> <a href="global.html#destroyCachedSprite">destroyCachedSprite</a> </li> <li class="class-depth-0"> <a href="global.html#displayList">displayList</a> </li> <li class="class-depth-0"> <a href="global.html#DOWN">DOWN</a> </li> <li class="class-depth-0"> <a href="global.html#drawCircle">drawCircle</a> </li> <li class="class-depth-0"> <a href="global.html#drawEllipse">drawEllipse</a> </li> <li class="class-depth-0"> <a href="global.html#drawPolygon">drawPolygon</a> </li> <li class="class-depth-0"> <a href="global.html#drawRect">drawRect</a> </li> <li class="class-depth-0"> <a href="global.html#drawRoundedRect">drawRoundedRect</a> </li> <li class="class-depth-0"> <a href="global.html#drawShape">drawShape</a> </li> <li class="class-depth-0"> <a href="global.html#ELLIPSE">ELLIPSE</a> </li> <li class="class-depth-0"> <a href="global.html#emit">emit</a> </li> <li class="class-depth-0"> <a href="global.html#EMITTER">EMITTER</a> </li> <li class="class-depth-0"> <a href="global.html#endFill">endFill</a> </li> <li class="class-depth-0"> <a href="global.html#GAMES">GAMES</a> </li> <li class="class-depth-0"> <a href="global.html#generateTexture">generateTexture</a> </li> <li class="class-depth-0"> <a href="global.html#getBounds">getBounds</a> </li> <li class="class-depth-0"> <a href="global.html#getLocalBounds">getLocalBounds</a> </li> <li class="class-depth-0"> <a href="global.html#GRAPHICS">GRAPHICS</a> </li> <li class="class-depth-0"> <a href="global.html#GROUP">GROUP</a> </li> <li class="class-depth-0"> <a href="global.html#HEADLESS">HEADLESS</a> </li> <li class="class-depth-0"> <a href="global.html#HORIZONTAL">HORIZONTAL</a> </li> <li class="class-depth-0"> <a href="global.html#IMAGE">IMAGE</a> </li> <li class="class-depth-0"> <a href="global.html#LANDSCAPE">LANDSCAPE</a> </li> <li class="class-depth-0"> <a href="global.html#LEFT">LEFT</a> </li> <li class="class-depth-0"> <a href="global.html#LEFT_BOTTOM">LEFT_BOTTOM</a> </li> <li class="class-depth-0"> <a href="global.html#LEFT_CENTER">LEFT_CENTER</a> </li> <li class="class-depth-0"> <a href="global.html#LEFT_TOP">LEFT_TOP</a> </li> <li class="class-depth-0"> <a href="global.html#LINE">LINE</a> </li> <li class="class-depth-0"> <a href="global.html#lineStyle">lineStyle</a> </li> <li class="class-depth-0"> <a href="global.html#lineTo">lineTo</a> </li> <li class="class-depth-0"> <a href="global.html#listeners">listeners</a> </li> <li class="class-depth-0"> <a href="global.html#MATRIX">MATRIX</a> </li> <li class="class-depth-0"> <a href="global.html#mixin">mixin</a> </li> <li class="class-depth-0"> <a href="global.html#moveTo">moveTo</a> </li> <li class="class-depth-0"> <a href="global.html#NONE">NONE</a> </li> <li class="class-depth-0"> <a href="global.html#off">off</a> </li> <li class="class-depth-0"> <a href="global.html#on">on</a> </li> <li class="class-depth-0"> <a href="global.html#once">once</a> </li> <li class="class-depth-0"> <a href="global.html#PENDING_ATLAS">PENDING_ATLAS</a> </li> <li class="class-depth-2"> <a href="global.html#Phaser.Path#numPointsreturn%257Bnumber%257DThetotalnumberofPathPointsinthisPath.">Phaser.Path#numPoints return {number} The total number of PathPoints in this Path.</a> </li> <li class="class-depth-0"> <a href="global.html#POINT">POINT</a> </li> <li class="class-depth-0"> <a href="global.html#POINTER">POINTER</a> </li> <li class="class-depth-0"> <a href="global.html#POLYGON">POLYGON</a> </li> <li class="class-depth-0"> <a href="global.html#PORTRAIT">PORTRAIT</a> </li> <li class="class-depth-0"> <a href="global.html#quadraticCurveTo">quadraticCurveTo</a> </li> <li class="class-depth-0"> <a href="global.html#RECTANGLE">RECTANGLE</a> </li> <li class="class-depth-0"> <a href="global.html#removeAllListeners">removeAllListeners</a> </li> <li class="class-depth-0"> <a href="global.html#RENDERTEXTURE">RENDERTEXTURE</a> </li> <li class="class-depth-0"> <a href="global.html#RETROFONT">RETROFONT</a> </li> <li class="class-depth-0"> <a href="global.html#RIGHT">RIGHT</a> </li> <li class="class-depth-0"> <a href="global.html#RIGHT_BOTTOM">RIGHT_BOTTOM</a> </li> <li class="class-depth-0"> <a href="global.html#RIGHT_CENTER">RIGHT_CENTER</a> </li> <li class="class-depth-0"> <a href="global.html#RIGHT_TOP">RIGHT_TOP</a> </li> <li class="class-depth-0"> <a href="global.html#ROPE">ROPE</a> </li> <li class="class-depth-0"> <a href="global.html#ROUNDEDRECTANGLE">ROUNDEDRECTANGLE</a> </li> <li class="class-depth-0"> <a href="global.html#scaleModes">scaleModes</a> </li> <li class="class-depth-0"> <a href="global.html#SPRITE">SPRITE</a> </li> <li class="class-depth-0"> <a href="global.html#SPRITEBATCH">SPRITEBATCH</a> </li> <li class="class-depth-0"> <a href="global.html#stopImmediatePropagation">stopImmediatePropagation</a> </li> <li class="class-depth-0"> <a href="global.html#stopPropagation">stopPropagation</a> </li> <li class="class-depth-0"> <a href="global.html#TEXT">TEXT</a> </li> <li class="class-depth-0"> <a href="global.html#TILEMAP">TILEMAP</a> </li> <li class="class-depth-0"> <a href="global.html#TILEMAPLAYER">TILEMAPLAYER</a> </li> <li class="class-depth-0"> <a href="global.html#TILESPRITE">TILESPRITE</a> </li> <li class="class-depth-0"> <a href="global.html#TOP_CENTER">TOP_CENTER</a> </li> <li class="class-depth-0"> <a href="global.html#TOP_LEFT">TOP_LEFT</a> </li> <li class="class-depth-0"> <a href="global.html#TOP_RIGHT">TOP_RIGHT</a> </li> <li class="class-depth-0"> <a href="global.html#UP">UP</a> </li> <li class="class-depth-0"> <a href="global.html#updateLocalBounds">updateLocalBounds</a> </li> <li class="class-depth-0"> <a href="global.html#VERSION">VERSION</a> </li> <li class="class-depth-0"> <a href="global.html#VERTICAL">VERTICAL</a> </li> <li class="class-depth-0"> <a href="global.html#VIDEO">VIDEO</a> </li> <li class="class-depth-0"> <a href="global.html#WEBGL">WEBGL</a> </li> <li class="class-depth-0"> <a href="global.html#WEBGL_FILTER">WEBGL_FILTER</a> </li> <li class="class-depth-0"> <a href="global.html#WEBGL_MULTI">WEBGL_MULTI</a> </li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Core<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-1"><a href="Phaser.Game.html">Game</a></li> <li class="class-depth-1"><a href="Phaser.Group.html">Group</a></li> <li class="class-depth-1"><a href="Phaser.World.html">World</a></li> <li class="class-depth-1"><a href="Phaser.Loader.html">Loader</a></li> <li class="class-depth-1"><a href="Phaser.Cache.html">Cache</a></li> <li class="class-depth-1"><a href="Phaser.Time.html">Time</a></li> <li class="class-depth-1"><a href="Phaser.Camera.html">Camera</a></li> <li class="class-depth-1"><a href="Phaser.StateManager.html">State Manager</a></li> <li class="class-depth-1"><a href="Phaser.TweenManager.html">Tween Manager</a></li> <li class="class-depth-1"><a href="Phaser.SoundManager.html">Sound Manager</a></li> <li class="class-depth-1"><a href="Phaser.Input.html">Input Manager</a></li> <li class="class-depth-1"><a href="Phaser.ScaleManager.html">Scale Manager</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Game Objects<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-1"><a href="Phaser.GameObjectFactory.html">Factory (game.add)</a></li> <li class="class-depth-1"><a href="Phaser.GameObjectCreator.html">Creator (game.make)</a></li> <li class="class-depth-1"><a href="Phaser.Sprite.html">Sprite</a></li> <li class="class-depth-1"><a href="Phaser.Image.html">Image</a></li> <li class="class-depth-1"><a href="Phaser.Sound.html">Sound</a></li> <li class="class-depth-1"><a href="Phaser.Video.html">Video</a></li> <li class="class-depth-1"><a href="Phaser.Particles.Arcade.Emitter.html">Particle Emitter</a></li> <li class="class-depth-1"><a href="Phaser.Particle.html">Particle</a></li> <li class="class-depth-1"><a href="Phaser.Text.html">Text</a></li> <li class="class-depth-1"><a href="Phaser.Tween.html">Tween</a></li> <li class="class-depth-1"><a href="Phaser.BitmapText.html">BitmapText</a></li> <li class="class-depth-1"><a href="Phaser.Tilemap.html">Tilemap</a></li> <li class="class-depth-1"><a href="Phaser.BitmapData.html">BitmapData</a></li> <li class="class-depth-1"><a href="Phaser.RetroFont.html">RetroFont</a></li> <li class="class-depth-1"><a href="Phaser.Button.html">Button</a></li> <li class="class-depth-1"><a href="Phaser.Animation.html">Animation</a></li> <li class="class-depth-1"><a href="Phaser.Graphics.html">Graphics</a></li> <li class="class-depth-1"><a href="Phaser.RenderTexture.html">RenderTexture</a></li> <li class="class-depth-1"><a href="Phaser.TileSprite.html">TileSprite</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Geometry<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-1"><a href="Phaser.Circle.html">Circle</a></li> <li class="class-depth-1"><a href="Phaser.Ellipse.html">Ellipse</a></li> <li class="class-depth-1"><a href="Phaser.Line.html">Line</a></li> <li class="class-depth-1"><a href="Phaser.Matrix.html">Matrix</a></li> <li class="class-depth-1"><a href="Phaser.Point.html">Point</a></li> <li class="class-depth-1"><a href="Phaser.Polygon.html">Polygon</a></li> <li class="class-depth-1"><a href="Phaser.Rectangle.html">Rectangle</a></li> <li class="class-depth-1"><a href="Phaser.RoundedRectangle.html">Rounded Rectangle</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Physics<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-1"><a href="Phaser.Physics.Arcade.html">Arcade Physics</a></li> <li class="class-depth-2"><a href="Phaser.Physics.Arcade.Body.html">Body</a></li> <li class="class-depth-2"><a href="Phaser.Weapon.html">Weapon</a></li> <li class="class-depth-1"><a href="Phaser.Physics.P2.html">P2 Physics</a></li> <li class="class-depth-2"><a href="Phaser.Physics.P2.Body.html">Body</a></li> <li class="class-depth-2"><a href="Phaser.Physics.P2.Spring.html">Spring</a></li> <li class="class-depth-2"><a href="Phaser.Physics.P2.CollisionGroup.html">CollisionGroup</a></li> <li class="class-depth-2"><a href="Phaser.Physics.P2.ContactMaterial.html">ContactMaterial</a></li> <li class="class-depth-1"><a href="Phaser.Physics.Ninja.html">Ninja Physics</a></li> <li class="class-depth-2"><a href="Phaser.Physics.Body.html">Body</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Input<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-1"><a href="Phaser.InputHandler.html">Input Handler</a></li> <li class="class-depth-1"><a href="Phaser.Pointer.html">Pointer</a></li> <li class="class-depth-1"><a href="Phaser.DeviceButton.html">Device Button</a></li> <li class="class-depth-1"><a href="Phaser.Mouse.html">Mouse</a></li> <li class="class-depth-1"><a href="Phaser.Keyboard.html">Keyboard</a></li> <li class="class-depth-1"><a href="Phaser.Key.html">Key</a></li> <li class="class-depth-1"><a href="Phaser.KeyCode.html">Key Codes</a></li> <li class="class-depth-1"><a href="Phaser.Gamepad.html">Gamepad</a></li> </ul> </li> <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Community<b class="caret"></b></a> <ul class="dropdown-menu "> <li class="class-depth-1"><a href="http://phaser.io">Phaser Web Site</a></li> <li class="class-depth-1"><a href="https://github.com/photonstorm/phaser">Phaser Github</a></li> <li class="class-depth-1"><a href="http://phaser.io/examples">Phaser Examples</a></li> <li class="class-depth-1"><a href="https://github.com/photonstorm/phaser-plugins">Phaser Plugins</a></li> <li class="class-depth-1"><a href="http://www.html5gamedevs.com/forum/14-phaser/">Forum</a></li> <li class="class-depth-1"><a href="http://stackoverflow.com/questions/tagged/phaser-framework">Stack Overflow</a></li> <li class="class-depth-1"><a href="http://phaser.io/learn">Tutorials</a></li> <li class="class-depth-1"><a href="http://phaser.io/community/newsletter">Newsletter</a></li> <li class="class-depth-1"><a href="http://phaser.io/community/twitter">Twitter</a></li> <li class="class-depth-1"><a href="http://phaser.io/community/slack">Slack</a></li> <li class="class-depth-1"><a href="http://phaser.io/community/donate">Donate</a></li> <li class="class-depth-1"><a href="https://www.codeandweb.com/texturepacker/phaser">Texture Packer</a></li> </ul> </li> </ul> </div> </div> <div class="row-fluid"> <div class="span12"> <div id="main"> <h1 class="page-title">Source: src/utils/LinkedList.js</h1> <section> <article> <pre class="sunlight-highlight-javascript linenums">/** * @author Richard Davey &lt;[email protected]> * @copyright 2016 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * A basic Linked List data structure. * * This implementation _modifies_ the `prev` and `next` properties of each item added: * - The `prev` and `next` properties must be writable and should not be used for any other purpose. * - Items _cannot_ be added to multiple LinkedLists at the same time. * - Only objects can be added. * * @class Phaser.LinkedList * @constructor */ Phaser.LinkedList = function () { /** * Next element in the list. * @property {object} next * @default */ this.next = null; /** * Previous element in the list. * @property {object} prev * @default */ this.prev = null; /** * First element in the list. * @property {object} first * @default */ this.first = null; /** * Last element in the list. * @property {object} last * @default */ this.last = null; /** * Number of elements in the list. * @property {integer} total * @default */ this.total = 0; }; Phaser.LinkedList.prototype = { /** * Adds a new element to this linked list. * * @method Phaser.LinkedList#add * @param {object} item - The element to add to this list. Can be a Phaser.Sprite or any other object you need to quickly iterate through. * @return {object} The item that was added. */ add: function (item) { // If the list is empty if (this.total === 0 &amp;&amp; this.first === null &amp;&amp; this.last === null) { this.first = item; this.last = item; this.next = item; item.prev = this; this.total++; return item; } // Gets appended to the end of the list, regardless of anything, and it won't have any children of its own (non-nested list) this.last.next = item; item.prev = this.last; this.last = item; this.total++; return item; }, /** * Resets the first, last, next and previous node pointers in this list. * * @method Phaser.LinkedList#reset */ reset: function () { this.first = null; this.last = null; this.next = null; this.prev = null; this.total = 0; }, /** * Removes the given element from this linked list if it exists. * * @method Phaser.LinkedList#remove * @param {object} item - The item to be removed from the list. */ remove: function (item) { if (this.total === 1) { this.reset(); item.next = item.prev = null; return; } if (item === this.first) { // It was 'first', make 'first' point to first.next this.first = this.first.next; } else if (item === this.last) { // It was 'last', make 'last' point to last.prev this.last = this.last.prev; } if (item.prev) { // make item.prev.next point to childs.next instead of item item.prev.next = item.next; } if (item.next) { // make item.next.prev point to item.prev instead of item item.next.prev = item.prev; } item.next = item.prev = null; if (this.first === null ) { this.last = null; } this.total--; }, /** * Calls a function on all members of this list, using the member as the context for the callback. * The function must exist on the member. * * @method Phaser.LinkedList#callAll * @param {function} callback - The function to call. */ callAll: function (callback) { if (!this.first || !this.last) { return; } var entity = this.first; do { if (entity &amp;&amp; entity[callback]) { entity[callback].call(entity); } entity = entity.next; } while (entity !== this.last.next); } }; Phaser.LinkedList.prototype.constructor = Phaser.LinkedList; </pre> </article> </section> </div> <div class="clearfix"></div> <footer> <span class="copyright"> Phaser Copyright © 2012-2016 Photon Storm Ltd. </span> <br /> <span class="jsdoc-message"> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Thu Mar 23 2017 14:18:05 GMT+0000 (GMT Standard Time) using the <a href="https://github.com/terryweiss/docstrap">DocStrap template</a>. </span> </footer> </div> <br clear="both"> </div> </div> <script src="scripts/sunlight.js"></script> <script src="scripts/sunlight.javascript.js"></script> <script src="scripts/sunlight-plugin.doclinks.js"></script> <script src="scripts/sunlight-plugin.linenumbers.js"></script> <script src="scripts/sunlight-plugin.menu.js"></script> <script src="scripts/jquery.min.js"></script> <script src="scripts/jquery.scrollTo.js"></script> <script src="scripts/jquery.localScroll.js"></script> <script src="scripts/bootstrap-dropdown.js"></script> <script src="scripts/toc.js"></script> <script> Sunlight.highlightAll({lineNumbers:true, showMenu: true, enableDoclinks :true}); </script> <script> $( function () { $( "#toc" ).toc( { anchorName : function(i, heading, prefix) { return $(heading).attr("id") || ( prefix + i ); }, selectors : "h1,h2,h3,h4", showAndHide : false, scrollTo : 60 } ); $( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" ); $( "#main span[id^='toc']" ).addClass( "toc-shim" ); } ); </script> </body> </html>
mit
dgilliam/Ref7
Ref7App/www/rules/IL_903.html
1581
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui"> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <title>ReffLaw -</title> <!-- Path to Framework7 Library CSS--> <link rel="stylesheet" href="css/framework7.min.css"> <!-- Path to your custom app styles--> <link rel="stylesheet" href="css/my-app.css"> <!-- fontawesome--> </head> <body> <div class="views"> <div class="view view-main"> <div class="navbar"> <div class="navbar-inner"> <div class="left"><a href="#" class="back link"><i class="icon icon-back-blue"></i><span>Article IX</span></a></div> <div class="center sliding">IL 903</div> </div> </div> </div> <div class="pages"> <div data-page="IL_903" class="page"> <div class="page-content"> <div class="content-block-title">Subscribing Witness' Testimony Unnecessary</div> <div class="content-block"> <div class="content-block-inner"> <p style="white-space:pre-line;">The testimony of a subscribing witness is not necessary to authenticate a writing unless required by the laws of the jurisdiction whose laws govern the validity of the writing.</p> </div> </div> </div> </div> </div> </div> </body> </html>
mit
ha-dai/Misskey
src/server/api/endpoints/notes/user-list-timeline.ts
5368
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import Note from '../../../../models/note'; import Mute from '../../../../models/mute'; import { pack } from '../../../../models/note'; import UserList from '../../../../models/user-list'; import { ILocalUser } from '../../../../models/user'; import getParams from '../../get-params'; export const meta = { desc: { ja: '指定したユーザーリストのタイムラインを取得します。', en: 'Get timeline of a user list.' }, requireCredential: true, params: { listId: $.type(ID).note({ desc: { ja: 'リストのID' } }), limit: $.num.optional.range(1, 100).note({ default: 10, desc: { ja: '最大数' } }), sinceId: $.type(ID).optional.note({ desc: { ja: '指定すると、この投稿を基点としてより新しい投稿を取得します' } }), untilId: $.type(ID).optional.note({ desc: { ja: '指定すると、この投稿を基点としてより古い投稿を取得します' } }), sinceDate: $.num.optional.note({ desc: { ja: '指定した時間を基点としてより新しい投稿を取得します。数値は、1970年1月1日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。' } }), untilDate: $.num.optional.note({ desc: { ja: '指定した時間を基点としてより古い投稿を取得します。数値は、1970年1月1日 00:00:00 UTC から指定した日時までの経過時間をミリ秒単位で表します。' } }), includeMyRenotes: $.bool.optional.note({ default: true, desc: { ja: '自分の行ったRenoteを含めるかどうか' } }), includeRenotedMyNotes: $.bool.optional.note({ default: true, desc: { ja: 'Renoteされた自分の投稿を含めるかどうか' } }), includeLocalRenotes: $.bool.optional.note({ default: true, desc: { ja: 'Renoteされたローカルの投稿を含めるかどうか' } }), mediaOnly: $.bool.optional.note({ desc: { ja: 'true にすると、メディアが添付された投稿だけ取得します' } }), } }; export default async (params: any, user: ILocalUser) => { const [ps, psErr] = getParams(meta, params); if (psErr) throw psErr; const [list, mutedUserIds] = await Promise.all([ // リストを取得 // Fetch the list UserList.findOne({ _id: ps.listId, userId: user._id }), // ミュートしているユーザーを取得 Mute.find({ muterId: user._id }).then(ms => ms.map(m => m.muteeId)) ]); if (list.userIds.length == 0) { return []; } //#region Construct query const sort = { _id: -1 }; const listQuery = list.userIds.map(u => ({ userId: u, // リプライは含めない(ただし投稿者自身の投稿へのリプライ、自分の投稿へのリプライ、自分のリプライは含める) $or: [{ // リプライでない replyId: null }, { // または // リプライだが返信先が投稿者自身の投稿 $expr: { $eq: ['$_reply.userId', '$userId'] } }, { // または // リプライだが返信先が自分(フォロワー)の投稿 '_reply.userId': user._id }, { // または // 自分(フォロワー)が送信したリプライ userId: user._id }] })); const query = { $and: [{ // リストに入っている人のタイムラインへの投稿 $or: listQuery, // mute userId: { $nin: mutedUserIds }, '_reply.userId': { $nin: mutedUserIds }, '_renote.userId': { $nin: mutedUserIds }, }] } as any; // MongoDBではトップレベルで否定ができないため、De Morganの法則を利用してクエリします。 // つまり、「『自分の投稿かつRenote』ではない」を「『自分の投稿ではない』または『Renoteではない』」と表現します。 // for details: https://en.wikipedia.org/wiki/De_Morgan%27s_laws if (ps.includeMyRenotes === false) { query.$and.push({ $or: [{ userId: { $ne: user._id } }, { renoteId: null }, { text: { $ne: null } }, { mediaIds: { $ne: [] } }, { poll: { $ne: null } }] }); } if (ps.includeRenotedMyNotes === false) { query.$and.push({ $or: [{ '_renote.userId': { $ne: user._id } }, { renoteId: null }, { text: { $ne: null } }, { mediaIds: { $ne: [] } }, { poll: { $ne: null } }] }); } if (ps.includeLocalRenotes === false) { query.$and.push({ $or: [{ '_renote.user.host': { $ne: null } }, { renoteId: null }, { text: { $ne: null } }, { mediaIds: { $ne: [] } }, { poll: { $ne: null } }] }); } if (ps.mediaOnly) { query.$and.push({ mediaIds: { $exists: true, $ne: [] } }); } if (ps.sinceId) { sort._id = 1; query._id = { $gt: ps.sinceId }; } else if (ps.untilId) { query._id = { $lt: ps.untilId }; } else if (ps.sinceDate) { sort._id = 1; query.createdAt = { $gt: new Date(ps.sinceDate) }; } else if (ps.untilDate) { query.createdAt = { $lt: new Date(ps.untilDate) }; } //#endregion // Issue query const timeline = await Note .find(query, { limit: ps.limit, sort: sort }); // Serialize return await Promise.all(timeline.map(note => pack(note, user))); };
mit
tf/pageflow
spec/features/entry_publisher/publishing_an_entry_spec.rb
2140
require 'spec_helper' feature 'as entry publisher, publishing an entry', js: true do scenario 'without depublication date' do entry = create(:entry, title: 'Test Entry') Dom::Admin::Page.sign_in_as(:publisher, on: entry) visit(pageflow.editor_entry_path(entry)) editor_sidebar = Dom::Editor::Sidebar.find! editor_sidebar.publish_button.click Dom::Editor::PublishEntryPanel.find!.publish Dom::Admin::EntryPage.visit_revisions(entry) expect(Dom::Admin::EntryRevision.published).to be_present end scenario 'with depublication date' do entry = create(:entry, title: 'Test Entry') Dom::Admin::Page.sign_in_as(:publisher, on: entry) visit(pageflow.editor_entry_path(entry)) editor_sidebar = Dom::Editor::Sidebar.find! editor_sidebar.publish_button.click Dom::Editor::PublishEntryPanel.find!.publish_until(1.month.from_now) Dom::Admin::EntryPage.visit_revisions(entry) expect(Dom::Admin::EntryRevision.published_until_date).to be_present end scenario 'with invalid depublication time' do entry = create(:entry, title: 'Test Entry') Dom::Admin::Page.sign_in_as(:publisher, on: entry) visit(pageflow.editor_entry_path(entry)) editor_sidebar = Dom::Editor::Sidebar.find! editor_sidebar.publish_button.click publish_panel = Dom::Editor::PublishEntryPanel.find! publish_panel.activate_publish_until publish_panel.set_depublication_date(1.month.from_now.strftime('%d.%m.%Y'), '40:30') expect(publish_panel.save_button).to be_disabled end scenario 'with password' do entry = create(:entry, title: 'Test Entry') Dom::Admin::Page.sign_in_as(:publisher, on: entry) visit(pageflow.editor_entry_path(entry)) editor_sidebar = Dom::Editor::Sidebar.find! editor_sidebar.publish_button.click publish_panel = Dom::Editor::PublishEntryPanel.find! publish_panel.activate_password_protection('abc213') publish_panel.publish Dom::Admin::EntryPage.visit_revisions(entry) published_revision = Dom::Admin::EntryRevision.published.first expect(published_revision).to be_password_protected end end
mit
adamhathcock/sharpcompress
src/SharpCompress/Compressors/Xz/XZIndexMarkerReachedException.cs
132
using System; namespace SharpCompress.Compressors.Xz { public class XZIndexMarkerReachedException : Exception { } }
mit
BenRomberg/cordonbleu
cordonbleu-data/src/test/java/com/benromberg/cordonbleu/data/migration/change0015/Change0015Test.java
1339
package com.benromberg.cordonbleu.data.migration.change0015; import static org.assertj.core.api.Assertions.assertThat; import com.benromberg.cordonbleu.data.migration.ChangeRule; import com.benromberg.cordonbleu.data.migration.TestCollection; import org.junit.Rule; import org.junit.Test; import com.benromberg.cordonbleu.data.migration.change0015.Change0015; public class Change0015Test { private static final String COMMIT_COLLECTION = "commit"; private static final String OTHER_FIELD = "other field"; private static final String COMMIT_ID = "commit-id"; @Rule public ChangeRule changeRule = new ChangeRule(Change0015.class); @Test public void convertUniqueFields_CanReadValues() throws Exception { TestCollection<CommitBefore> collectionBefore = changeRule.getCollection(COMMIT_COLLECTION, CommitBefore.class); CommitBefore commitBefore = new CommitBefore(COMMIT_ID, OTHER_FIELD); collectionBefore.insert(commitBefore); changeRule.runChanges(); TestCollection<CommitAfter> collectionAfter = changeRule.getCollection(COMMIT_COLLECTION, CommitAfter.class); CommitAfter userAfter = collectionAfter.findOneById(COMMIT_ID); assertThat(userAfter.getOtherField()).isEqualTo(OTHER_FIELD); assertThat(userAfter.isRemoved()).isFalse(); } }
mit
zz-systems/zacc
README.md
18604
# ZACC [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/ea9a6858d3e24f54b342a7baba064d3f)](https://www.codacy.com/app/sergej-zuyev/zacc?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=zz-systems/zacc&amp;utm_campaign=Badge_Grade) | Branch | Travis CI | AppVeyorCI | |-----------|------------|----| | Master | [![Build Status](https://travis-ci.org/zz-systems/zacc.svg?branch=master)](https://travis-ci.org/zz-systems/zacc) | [![Build status](https://ci.appveyor.com/api/projects/status/j2pe355ld0pt60sq/branch/master?svg=true)](https://ci.appveyor.com/project/zz-systems/zacc/branch/master) | | Develop | [![Build Status](https://travis-ci.org/zz-systems/zacc.svg?branch=develop)](https://travis-ci.org/zz-systems/zacc) | [![Build status](https://ci.appveyor.com/api/projects/status/j2pe355ld0pt60sq/branch/develop?svg=true)](https://ci.appveyor.com/project/zz-systems/zacc/branch/develop) | - [Abstract](#abstract) - [Design goals](#design-goals) - [Features](#features) - [Integration](#integration) - [Usage](#usage) - [Mandelbrot kernel interface](#mandelbrot-kernel-interface) - [Mandelbrot kernel implementation](#mandelbrot-kernel-implementation) - [Entrypoint](#entrypoint) - [Execution](#execution) - [Build system](#build-system) - [Prequisites](#prequisites) - [Library target](#library-target) - [Executable target](#executable-target) - [Unit test target](#unit-test-target) - [Current state](#current-state) - [Tested hardware](#tested-hardware) - [Tested operating systems](#tested-operating-systems) - [Architecture support](#architecture-support) - [Compiler support](#compiler-support) - [Supported data types](#supported-data-types) - [License](#license) - [Execute unit tests](#execute-unit-tests) ## Abstract ZACC is a human-readable and extensible computation abstraction layer. Using ZACC and ZACC build, you are able to write and compile code once and execute it on target machines, unleashing their potential. It is still under development which is synchronous to [cacophony](https://github.com/zz-systems/cacophony) development. Feel free to report issues and bugs to the [Issue tracker on GitHub](https://github.com/zz-systems/zacc/issues) [Documentation](http://zz-systems.github.io/zacc/htmldoc/index.html) ## Design goals There a few SIMD Libraries available, like [Eigen](http://eigen.tuxfamily.org/index.php?title=Main_Page) or [Agner Fog's vector class library](http://www.agner.org/optimize/#vectorclass), each of them following the same goal: accelerate your algorithms by using SIMD instructions. ZACC implementation had these goals: - **Coding as if you would write vanilla C++.** ```std::cout << (zint(32) % 16) << std::endl;``` prints ```[0, 0, 0, 0]``` if SSE extensions are used. - **DRY.** *Write once, run faster everywhere* - **Runtime feature selection.** The dispatcher checks the system features and selects the best fitting implementation. - **Easy integration.** ZACC offers cmake scripts to build your project. - **Portability.** ZACC accelerated projects should be able to run on any OS and any processor. - **Speed.** Although ZACC may be not the highest-optimized library in the world, speed combined with a great usability is a high priority. ## Features * Linear algebra support * Arithmetic operations * Conditional operations * Rounding operations * Standard functions like abs, min, max, etc... * Trigonometric functions (sin, cos, tan) * Platform detection * Runtime dispatching * Kernel infrastructure * Extended algorithms (STL-compatible) * Uses vanilla C++14 ## Integration The project is available as a direct submodule if you use git or [released here](https://github.com/zz-systems/zacc/releases). If you decide for the submodule way, simply add it via ```git submodule add https://github.com/zz-systems/zacc.git``` CMake is required in your project to be able to use ZACC and [ZACC build system](#build-system). ## Usage To execute an accelerated algorithm, you need a kernel interface, a kernel implementation and an entrypoint. ### Mandelbrot kernel interface The kernel interface is the connection between the vectorized code in satellite assemblies and the main application. The separation is necessary, because the kernel implementation uses vector types, which **must not** appear in the main application and are hidden in satellite assemblies. The vital function mapping for the dispatcher is provided by ```system::kernel_interface<_KernelInterface>``` (The dispatcher relies on ```operator()(...)``` overloads). 3 methods are already mapped, you have to declare them in the interface and implement in the kernel: - ```run(output_container_t &output)``` - ```run(const input_container &input, output_container &output)``` - ```configure(any argument...)``` You can extend or change the mappings with your custom implementation. Also, you need to specify the input and output container types and provide a name for the kernel. Below is an exemplary mandelbrot kernel interface - available in the examples. ```cpp #include <vector> #include "zacc.hpp" #include "math/matrix.hpp" #include "util/algorithm.hpp" #include "system/entrypoint.hpp" #include "system/kernel_interface.hpp" using namespace zacc; using namespace math; struct __mandelbrot { using output_container = std::vector<int>; using input_container = std::vector<int>; static constexpr auto kernel_name() { return "mandelbrot"; } virtual void configure(vec2<int> dim, vec2<float> cmin, vec2<float> cmax, size_t max_iterations) = 0; virtual void run(output_container_t &output) = 0; }; using mandelbrot = system::kernel_interface<__mandelbrot>; ``` ### Mandelbrot kernel implementation Now that you have specified the kernel interface, you may want to write the implementation. Please have in mind, that C++ own if/else won't work with vector types. You need to rethink and use branchless arithmetic. Nonetheless, the implementation does not differ much from the canonical Mandelbrot [implementation](https://rosettacode.org/wiki/Mandelbrot_set#C.2B.2B) and is able to use SSE2, SSE3, SSE4, FMA, AVX, AVX2 features of the host processor. And all that without having to touch intrinsics like [here](https://github.com/PolarNick239/FPGABenchmarks/blob/c36b213bed3fbf6c714f3a819e820d3d393c9711/benchmarks/mandelbrot/src/mandelbrot_cpu_sse.cpp#L20-L81) *Write once, run faster everywhere :)* ```cpp #include "zacc.hpp" #include "math/complex.hpp" #include "math/matrix.hpp" #include "util/algorithm.hpp" #include "system/kernel.hpp" #include "../interfaces/mandelbrot.hpp" using namespace zacc; using namespace math; DISPATCHED struct mandelbrot_kernel : system::kernel<mandelbrot>, allocatable<mandelbrot_kernel, arch> { vec2<zint> _dim; vec2<zfloat> _cmin; vec2<zfloat> _cmax; size_t _max_iterations; virtual void configure(vec2<int> dim, vec2<float> cmin, vec2<float> cmax, size_t max_iterations) override { _dim = dim; _cmax = cmax; _cmin = cmin; _max_iterations = max_iterations; } virtual void run(mandelbrot::output_container &output) override { // populate output container zacc::generate<zint>(std::begin(output), std::end(output), [this](auto i) { // compute 2D-position from 1D-index auto pos = reshape<vec2<zfloat>>(make_index<zint>(zint(i)), _dim); zcomplex<zfloat> c(_cmin.x + pos.x / zfloat(_dim.x - 1) * (_cmax.x - _cmin.x), _cmin.y + pos.y / zfloat(_dim.y - 1) * (_cmax.y - _cmin.x)); zcomplex<zfloat> z = 0; bfloat done = false; zint iterations; for (size_t j = 0; j < _max_iterations; j++) { // done when magnitude is >= 2 (or square magnitude is >= 4) done = done || z.sqr_magnitude() >= 4.0; // compute next complex if not done z = z .when(done) .otherwise(z * z + c); // increment if not done iterations = iterations .when(done) .otherwise(iterations + 1); // break if all elements are not zero if (is_set(done)) break; } return iterations; }); } }; ``` ### Entrypoint The so-called entrypoint is the low-level interface between the main application and vectorized implementations. Over this interface, the kernels are created and destroyed. #### entrypoint.hpp Here you declare your available kernel 'constructors' and 'destructors'. The convention is ```{kernel_name}_create_instance()``` and ```{kernel_name}_delete_instance(entrypoint *)```. ```cpp #include "{your_application_name}_arch_export.hpp" #include "system/entrypoint.hpp" extern "C" { {your_application_name}_ARCH_EXPORT zacc::system::entrypoint *mandelbrot_create_instance(); {your_application_name}_ARCH_EXPORT void mandelbrot_delete_instance(zacc::system::entrypoint *instance); } ``` #### entrypoint.cpp Here you implement your available kernel 'constructors' and 'destructors'. Usually, simply instantiating/deleting a kernel is sufficient, but a more complex logic can be introduced. ```cpp #include "entrypoint.hpp" #include "system/arch.hpp" #include "kernels/mandelbrot.hpp" // create mandelbrot kernel instance zacc::system::entrypoint *mandelbrot_create_instance() { return new zacc::examples::mandelbrot_kernel<zacc::arch::types>(); } // destroy mandelbrot kernel instance void mandelbrot_delete_instance(zacc::system::entrypoint* instance) { if(instance != nullptr) delete instance; } ``` ### Execution Here you need to create a dispatcher for your kernel and configure / invoke the kernel. The kernel invocation happens inside the dispatcher, which acts as a proxy. The dispatcher offers the following methods - ```dispatch_some(...)``` - dispatch on all available architectures (e.g kernel configuration) - ```dispatch_one(...)``` - dispatch on the best available architecture (e.g kernel execution) ```cpp #include "../interfaces/mandelbrot.hpp" #include "system/kernel_dispatcher.hpp" #include "math/matrix.hpp" // mandelbrot config: vec2<int> dimensions = {2048, 2048}; vec2<float> cmin = {-2, -2}; vec2<float> cmax = { 2, 2 }; size_t max_iterations = 2048; // get kernel dispatcher auto dispatcher = system::make_dispatcher<mandelbrot>(); // configure kernel dispatcher.dispatch_some(_dim, cmin, cmax, max_iterations); // prepare output std::vector<int>(_dim.x * _dim.y); // run dispatcher.dispatch_one(result); ... ``` ## Build system ### Prequisites ```cmake # add zacc targets add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zacc) # use zacc build system include(${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zacc/cmake/zacc.shared.cmake) # add include lookup directories include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/zacc/include ) ``` ### Library target Defines a shared/dynamic library with dispatcher and kernel implementations in additional libraries. ```cmake # your shared library which aggregates the branches zacc_add_dispatched_library(_your_library_ # your library entrypoint ENTRYPOINT ${CMAKE_SOURCE_DIR}/_your_library_entrypoint.cpp # additional includes INCLUDES ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/dependencies/zacc/include # branches to build for BRANCHES "${branches}" # your main library source SOURCES ${CMAKE_SOURCE_DIR}/_your_library_.cpp ) ``` ### Executable target Defines a main application with dispatcher and kernel implementations in additional libraries. ```cmake zacc_add_dispatched_executable(_your_application_ # branches to build for BRANCHES "${branches}" # additional includes INCLUDES ${PROJECT_SOURCE_DIR}/include # your kernel entrypoint ENTRYPOINT ${PROJECT_SOURCE_DIR}/_your_application_entrypoint.cpp # your main application sources SOURCES ${PROJECT_SOURCE_DIR}/_your_application_.cpp ) ``` ### Unit test target Defines unit test targets using GoogleTest ```cmake # unit testing your implementation on all branches # find the test main (you may provide your own implementation) file(GLOB ZACC_TEST_MAIN "${PROJECT_SOURCE_DIR}/*/zacc/*/test_main.cpp") # find the test entry point (you may provide your own implementation) file(GLOB ZACC_TEST_ENTRYPOINT "${PROJECT_SOURCE_DIR}/*/zacc/*/test_entry_point.cpp") zacc_add_dispatched_tests(_your_tests_ # test main. used to skip the tests if the processing unit is not # capable of running a particular featureset TEST_MAIN ${ZACC_TEST_MAIN} # gtest main TEST_ENTRYPOINT ${ZACC_TEST_ENTRYPOINT} # branches to build for BRANCHES "${branches}" # additional include directories INCLUDES ${CMAKE_SOURCE_DIR}/include # your test sources SOURCES ${_your_test_files_here} ) ``` ## Current state * In development! * Used in [cacophony](https://github.com/zz-systems/cacophony) - a coherent noise library ### Tested hardware: | Processor | Highest featureset | |-----------|------------| | AMD FX-8350 | AVX1 | | Intel Core i7 6500U | AVX2 + FMA | | Intel Core i7 7700K | AVX2 + FMA | | Intel Xeon E5-2697 v3 | AVX2 + FMA | | Intel Xeon E5-2680 v3 | AVX2 + FMA | | Intel Xeon E5-2680 v2 | AVX1 | | Intel Xeon X5570 | SSE4.1 | ### Tested operating systems - Mac OS X Sierra / High Sierra - Linux - Windows 10 ### Architecture support | Featureset | State | | |-----------|---|--------------| | x87 FPU | :white_check_mark: | scalar | | SSE2 | :white_check_mark: | | | SSE3 | :white_check_mark: | | SSE3 + SSSE3 | :white_check_mark: | | SSE4.1 | :white_check_mark: | | SSE4.1 + FMA3 | :white_check_mark: | | SSE4.1 + FMA4 | :white_check_mark: | | AVX1 | :no_entry: | Integer vector emulation faulty. | | AVX1 + FMA3 | :no_entry: | Integer vector emulation faulty. | | AVX2 | :white_check_mark: | | | AVX512 | :no_entry: | in development, can't be tested yet* | | ARM NEON | :no_entry: | Not implemented yet | | GPGPU | :no_entry: | Not implemented yet** | | FPGA | :no_entry: | Not implemented yet*** | *For AVX512, access to a Xeon Phi accelerator or a modern Xeon CPU is necessary **Some work is already done for the OpenCL implementation. Some macros or C++ code postprocessing may be introduced. ***Same starting issues as for the GPGPU feature, the code generation is another topic. ### Compiler support | Compiler | State | | |-----------|---|--------------| | GCC 5 | :white_check_mark: | | | GCC 6 | :white_check_mark: | | | GCC 7 | :white_check_mark: | | | Clang 3.9 | :no_entry: | Not compilable | | Clang 4.0 | :white_check_mark: | | | LLVM version 8.1.0 | :no_entry: | Not compilable | | LLVM version 9.0.0 | :white_check_mark: | | | Clang-cl | :white_check_mark: | | | MSVC | :no_entry: | Not supported* | *MSVC is not supported due to required fine granular compile options and non-conform C++ implementation. Instead Clang-cl is used, which is binary compatible with MSVC ([work in progress](https://clang.llvm.org/docs/MSVCCompatibility.html)). ### Supported data types | C++ scalar type | ZACC vector type | State | | |-----------|---|---|--------------| | signed int8 | zint8, zbyte | :white_check_mark: | Partially emulated. | | signed int16 | zint16, zshort | :white_check_mark: | | | signed int32 | zint32, zint | :white_check_mark: | | | signed int64 | zint64, zlong | :no_entry: | Not implemented yet | | float16 | zfloat16 | :no_entry: | Not implemented yet | | float32| zfloat, zfloat32 | :white_check_mark: | | | float64 | zdouble, zfloat64 | :white_check_mark: | | ## License <img align="right" src="http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png"> The library is licensed under the [MIT License](http://opensource.org/licenses/MIT): Copyright &copy; 2015-2018 Sergej Zuyev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ## Execute unit tests To compile and run the tests, you need to execute ``` $ make zacc.tests.all $ ctest -------------------------------------------------------------------- Start 1: ci.zacc.tests.scalar 1/8 Test #1: ci.zacc.tests.scalar ............. Passed 0.01 sec Start 2: ci.zacc.tests.sse.sse2 2/8 Test #2: ci.zacc.tests.sse.sse2 ........... Passed 0.01 sec Start 3: ci.zacc.tests.sse.sse3 3/8 Test #3: ci.zacc.tests.sse.sse3 ........... Passed 0.01 sec Start 4: ci.zacc.tests.sse.sse41 4/8 Test #4: ci.zacc.tests.sse.sse41 .......... Passed 0.01 sec Start 5: ci.zacc.tests.sse.sse41.fma3 5/8 Test #5: ci.zacc.tests.sse.sse41.fma3 ..... Passed 0.01 sec Start 6: ci.zacc.tests.sse.sse41.fma4 6/8 Test #6: ci.zacc.tests.sse.sse41.fma4 ..... Passed 0.00 sec Start 7: ci.zacc.tests.avx 7/8 Test #7: ci.zacc.tests.avx ................ Passed 0.01 sec Start 8: ci.zacc.tests.avx2 8/8 Test #8: ci.zacc.tests.avx2 ............... Passed 0.01 sec 100% tests passed, 0 tests failed out of 8 Total Test time (real) = 0.11 sec ```
mit
jim-parry/CodeIgniter4
system/HTTP/Negotiate.php
11335
<?php /** * CodeIgniter * * An open source application development framework for PHP * * This content is released under the MIT License (MIT) * * Copyright (c) 2014-2019 British Columbia Institute of Technology * Copyright (c) 2019 CodeIgniter Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. * * @package CodeIgniter * @author CodeIgniter Dev Team * @copyright 2019 CodeIgniter Foundation * @license https://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 4.0.0 * @filesource */ namespace CodeIgniter\HTTP; use CodeIgniter\HTTP\Exceptions\HTTPException; /** * Class Negotiate * * Provides methods to negotiate with the HTTP headers to determine the best * type match between what the application supports and what the requesting * getServer wants. * * @see http://tools.ietf.org/html/rfc7231#section-5.3 * @package CodeIgniter\HTTP */ class Negotiate { /** * Request * * @var \CodeIgniter\HTTP\RequestInterface|\CodeIgniter\HTTP\IncomingRequest */ protected $request; //-------------------------------------------------------------------- /** * Constructor * * @param \CodeIgniter\HTTP\RequestInterface $request */ public function __construct(RequestInterface $request = null) { if (! is_null($request)) { $this->request = $request; } } //-------------------------------------------------------------------- /** * Stores the request instance to grab the headers from. * * @param RequestInterface $request * * @return $this */ public function setRequest(RequestInterface $request) { $this->request = $request; return $this; } //-------------------------------------------------------------------- /** * Determines the best content-type to use based on the $supported * types the application says it supports, and the types requested * by the client. * * If no match is found, the first, highest-ranking client requested * type is returned. * * @param array $supported * @param boolean $strictMatch If TRUE, will return an empty string when no match found. * If FALSE, will return the first supported element. * * @return string */ public function media(array $supported, bool $strictMatch = false): string { return $this->getBestMatch($supported, $this->request->getHeaderLine('accept'), true, $strictMatch); } //-------------------------------------------------------------------- /** * Determines the best charset to use based on the $supported * types the application says it supports, and the types requested * by the client. * * If no match is found, the first, highest-ranking client requested * type is returned. * * @param array $supported * * @return string */ public function charset(array $supported): string { $match = $this->getBestMatch($supported, $this->request->getHeaderLine('accept-charset'), false, true); // If no charset is shown as a match, ignore the directive // as allowed by the RFC, and tell it a default value. if (empty($match)) { return 'utf-8'; } return $match; } //-------------------------------------------------------------------- /** * Determines the best encoding type to use based on the $supported * types the application says it supports, and the types requested * by the client. * * If no match is found, the first, highest-ranking client requested * type is returned. * * @param array $supported * * @return string */ public function encoding(array $supported = []): string { array_push($supported, 'identity'); return $this->getBestMatch($supported, $this->request->getHeaderLine('accept-encoding')); } //-------------------------------------------------------------------- /** * Determines the best language to use based on the $supported * types the application says it supports, and the types requested * by the client. * * If no match is found, the first, highest-ranking client requested * type is returned. * * @param array $supported * * @return string */ public function language(array $supported): string { return $this->getBestMatch($supported, $this->request->getHeaderLine('accept-language')); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- // Utility Methods //-------------------------------------------------------------------- /** * Does the grunt work of comparing any of the app-supported values * against a given Accept* header string. * * Portions of this code base on Aura.Accept library. * * @param array $supported App-supported values * @param string $header header string * @param boolean $enforceTypes If TRUE, will compare media types and sub-types. * @param boolean $strictMatch If TRUE, will return empty string on no match. * If FALSE, will return the first supported element. * * @return string Best match */ protected function getBestMatch(array $supported, string $header = null, bool $enforceTypes = false, bool $strictMatch = false): string { if (empty($supported)) { throw HTTPException::forEmptySupportedNegotiations(); } if (empty($header)) { return $strictMatch ? '' : $supported[0]; } $acceptable = $this->parseHeader($header); foreach ($acceptable as $accept) { // if acceptable quality is zero, skip it. if ($accept['q'] === 0.0) { continue; } // if acceptable value is "anything", return the first available if ($accept['value'] === '*' || $accept['value'] === '*/*') { return $supported[0]; } // If an acceptable value is supported, return it foreach ($supported as $available) { if ($this->match($accept, $available, $enforceTypes)) { return $available; } } } // No matches? Return the first supported element. return $strictMatch ? '' : $supported[0]; } //-------------------------------------------------------------------- /** * Parses an Accept* header into it's multiple values. * * This is based on code from Aura.Accept library. * * @param string $header * * @return array */ public function parseHeader(string $header): array { $results = []; $acceptable = explode(',', $header); foreach ($acceptable as $value) { $pairs = explode(';', $value); $value = $pairs[0]; unset($pairs[0]); $parameters = []; foreach ($pairs as $pair) { $param = []; preg_match( '/^(?P<name>.+?)=(?P<quoted>"|\')?(?P<value>.*?)(?:\k<quoted>)?$/', $pair, $param ); $parameters[trim($param['name'])] = trim($param['value']); } $quality = 1.0; if (array_key_exists('q', $parameters)) { $quality = $parameters['q']; unset($parameters['q']); } $results[] = [ 'value' => trim($value), 'q' => (float) $quality, 'params' => $parameters, ]; } // Sort to get the highest results first usort($results, function ($a, $b) { if ($a['q'] === $b['q']) { $a_ast = substr_count($a['value'], '*'); $b_ast = substr_count($b['value'], '*'); // '*/*' has lower precedence than 'text/*', // and 'text/*' has lower priority than 'text/plain' // // This seems backwards, but needs to be that way // due to the way PHP7 handles ordering or array // elements created by reference. if ($a_ast > $b_ast) { return 1; } // If the counts are the same, but one element // has more params than another, it has higher precedence. // // This seems backwards, but needs to be that way // due to the way PHP7 handles ordering or array // elements created by reference. if ($a_ast === $b_ast) { return count($b['params']) - count($a['params']); } return 0; } // Still here? Higher q values have precedence. return ($a['q'] > $b['q']) ? -1 : 1; }); return $results; } //-------------------------------------------------------------------- /** * Match-maker * * @param array $acceptable * @param string $supported * @param boolean $enforceTypes * @return boolean */ protected function match(array $acceptable, string $supported, bool $enforceTypes = false): bool { $supported = $this->parseHeader($supported); if (is_array($supported) && count($supported) === 1) { $supported = $supported[0]; } // Is it an exact match? if ($acceptable['value'] === $supported['value']) { return $this->matchParameters($acceptable, $supported); } // Do we need to compare types/sub-types? Only used // by negotiateMedia(). if ($enforceTypes) { return $this->matchTypes($acceptable, $supported); } return false; } //-------------------------------------------------------------------- /** * Checks two Accept values with matching 'values' to see if their * 'params' are the same. * * @param array $acceptable * @param array $supported * * @return boolean */ protected function matchParameters(array $acceptable, array $supported): bool { if (count($acceptable['params']) !== count($supported['params'])) { return false; } foreach ($supported['params'] as $label => $value) { if (! isset($acceptable['params'][$label]) || $acceptable['params'][$label] !== $value) { return false; } } return true; } //-------------------------------------------------------------------- /** * Compares the types/subtypes of an acceptable Media type and * the supported string. * * @param array $acceptable * @param array $supported * * @return boolean */ public function matchTypes(array $acceptable, array $supported): bool { list($aType, $aSubType) = explode('/', $acceptable['value']); list($sType, $sSubType) = explode('/', $supported['value']); // If the types don't match, we're done. if ($aType !== $sType) { return false; } // If there's an asterisk, we're cool if ($aSubType === '*') { return true; } // Otherwise, subtypes must match also. return $aSubType === $sSubType; } //-------------------------------------------------------------------- }
mit
umts/garrulous-garbanzo
db/migrate/20150909204238_create_users.rb
262
class CreateUsers < ActiveRecord::Migration[5.1] def change create_table :users do |t| t.string :first_name t.string :last_name t.string :spire t.string :email t.string :phone t.timestamps null: false end end end
mit
8l/ucc-c-compiler
src/util/dynmap.h
1897
#ifndef DYNMAP_H #define DYNMAP_H typedef struct dynmap dynmap; /* 0 for match, non-zero for mismatch */ typedef int dynmap_cmp_f(void *, void *); typedef unsigned dynmap_hash_f(const void *); dynmap *dynmap_nochk_new(dynmap_cmp_f, dynmap_hash_f); void dynmap_free(dynmap *); void *dynmap_nochk_get(dynmap *, void *key); void *dynmap_nochk_set(dynmap *, void *key, void *val); /* keys may be null, so: */ int dynmap_nochk_exists(dynmap *, void *key); void *dynmap_nochk_key(dynmap *map, int i); void *dynmap_nochk_value(dynmap *map, int i); void *dynmap_nochk_rm(dynmap *, void *key); void dynmap_dump(dynmap *); /* handy */ unsigned dynmap_strhash(const char *); #include "dyn.h" #define NO_EVAL(expr) (void)(0 ? (expr) : 0) /* don't eval the hash functions, but put a call to it for warning's sake * can't call the cmpf, since it may be NULL and we get a compile time error */ #define dynmap_new(type_k, cmpf, hashf) \ ((NO_EVAL(hashf((type_k)0))), \ dynmap_nochk_new((dynmap_cmp_f *)cmpf, (dynmap_hash_f *)hashf)) #define dynmap_get(type_k, type_v, map, key) \ (UCC_TYPECHECK(type_k, key), \ (type_v)dynmap_nochk_get(map, (void *)key)) #define dynmap_set(type_k, type_v, map, key, value) \ (UCC_TYPECHECK(type_k, key), \ UCC_TYPECHECK(type_v, value), \ (type_v)dynmap_nochk_set(map, (void *)key, (void *)value)) #define dynmap_key(type_k, map, idx) \ ((type_k)dynmap_nochk_key(map, idx)) #define dynmap_value(type_v, map, idx) \ ((type_v)dynmap_nochk_value(map, idx)) #define dynmap_exists(type_k, map, key) \ (UCC_TYPECHECK(type_k, key), \ dynmap_nochk_exists(map, key)) #define dynmap_rm(type_k, type_v, map, key) \ (UCC_TYPECHECK(type_k, key), \ (type_v)dynmap_nochk_rm(map, key)) #endif
mit
liebharc/VerifyBuffer
VerifyBuffering/CSharpCodeSnippets/DoubleArrayCreation.cs
1190
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CSharpCodeSnippets { public class DoubleArrayCreation { public double[][] ScaleArrays(double[][] arrays, double scalingFactor) { var result = new double[arrays.Length][]; for (int i = 0; i < arrays.Length; i++) { result[i] = ScaleArray(arrays[i], scalingFactor); } return result; } public double[] ScaleArray(double[] array, double scalingFactor) { var result = new double[array.Length]; for (int i = 0; i < array.Length; i++) result[i] = array[i] * scalingFactor; return result; } private const int Zero = 0; private static readonly double[] Empty = new double[Zero]; private static readonly double[] Empty2 = new double[Zero2]; private const int Zero2 = 0; public void EmptyArray() { const int Two = 2; var result = new double[Two]; } } }
mit
LeChosenOne/LegendCraft
fCraft/Drawing/DrawOps/WallsOp.cs
3853
//Copyright (C) <2012> <Jon Baker, Glenn Mariën and Lao Tszy> //This program is free software: you can redistribute it and/or modify //it under the terms of the GNU General Public License as published by //the Free Software Foundation, either version 3 of the License, or //(at your option) any later version. //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. //You should have received a copy of the GNU General Public License //along with this program. If not, see <http://www.gnu.org/licenses/>. //Copyright (C) <2012> Jon Baker(http://au70.net) using System; using System.Collections.Generic; namespace fCraft.Drawing { public sealed class WallsDrawOperation : DrawOperation { bool fillInner; public override string Name { get { return "Walls"; } } public override string Description { get { return Name; } } public WallsDrawOperation(Player player) : base(player){ } public override bool Prepare(Vector3I[] marks) { if (!base.Prepare(marks)) return false; fillInner = Brush.HasAlternateBlock && Bounds.Width > 2 && Bounds.Length > 2 && Bounds.Height > 2; BlocksTotalEstimate = Bounds.Volume; if (!fillInner) { BlocksTotalEstimate -= Math.Max(0, Bounds.Width - 2) * Math.Max(0, Bounds.Length - 2) * Math.Max(0, Bounds.Height - 2); } coordEnumerator = BlockEnumerator().GetEnumerator(); return true; } IEnumerator<Vector3I> coordEnumerator; public override int DrawBatch(int maxBlocksToDraw) { int blocksDone = 0; while (coordEnumerator.MoveNext()) { Coords = coordEnumerator.Current; if (DrawOneBlock()) { blocksDone++; if (blocksDone >= maxBlocksToDraw) return blocksDone; } } IsDone = true; return blocksDone; } //all works. Maybe look at Block estimation. IEnumerable<Vector3I> BlockEnumerator() { for (int x = Bounds.XMin; x <= Bounds.XMax; x++) { for (int z = Bounds.ZMin - 1; z < Bounds.ZMax; z++) { yield return new Vector3I(x, Bounds.YMin, z + 1); if (Bounds.YMin != Bounds.YMax) { yield return new Vector3I(x, Bounds.YMax, z + 1); } } for (int y = Bounds.YMin; y < Bounds.YMax; y++) { for (int z = Bounds.ZMin - 1; z < Bounds.ZMax; z++) { yield return new Vector3I(Bounds.XMin, y, z + 1); if (Bounds.XMin != Bounds.XMax) { yield return new Vector3I(Bounds.XMax, y, z + 1); } } } } if (fillInner) { UseAlternateBlock = true; for (int x = Bounds.XMin + 1; x < Bounds.XMax; x++) { for (int y = Bounds.YMin + 1; y < Bounds.YMax; y++) { for (int z = Bounds.ZMin; z < Bounds.ZMax + 1; z++) { yield return new Vector3I(x, y, z); } } } } } } }
mit
ucsd-cse-spis-2016/ucsd-cse-spis-2016.github.io
_layouts/lab.html
668
<!DOCTYPE html> <html lang="en"> <head> {% include head_lab.html %} <title>{{ page.num }} - {{ page.desc }} - {{course}}</title> </head> <body id="page-top"> <div id="container" data-role="page"> {% include nav.html %} <div id="content" class="ui-content"> <h1>{{page.num}} : {{page.desc}}</h1> <table class="asn_table"> {% include asn_table_header_row.html %} {% assign asn = page %} {% include asn_table_row.html %} </table> {{ content }} </div><!-- content --> {% include footer.html %} </div><!-- container --> </body> </html>
mit
CCPorg/FRK-Franko-Ver-80501-Copy
src/json/json_spirit_writer_template.h
6893
#ifndef JSON_SPIRIT_WRITER_TEMPLATE #define JSON_SPIRIT_WRITER_TEMPLATE // Copyright John W. Wilkinson 2007 - 2009. // Distributed under the MIT License, see accompanying file LICENSE.txt // json spirit version 4.03 #include "json_spirit_value.h" #include <cassert> #include <sstream> #include <iomanip> namespace json_spirit { inline char to_hex_char( unsigned int c ) { assert( c <= 0xF ); const char ch = static_cast< char >( c ); if( ch < 10 ) return '0' + ch; return 'A' - 10 + ch; } template< class String_type > String_type non_printable_to_string( unsigned int c ) { // silence error // typedef typename String_type::value_type Char_type; String_type result( 6, '\\' ); result[1] = 'u'; result[ 5 ] = to_hex_char( c & 0x000F ); c >>= 4; result[ 4 ] = to_hex_char( c & 0x000F ); c >>= 4; result[ 3 ] = to_hex_char( c & 0x000F ); c >>= 4; result[ 2 ] = to_hex_char( c & 0x000F ); return result; } template< typename Char_type, class String_type > bool add_esc_char( Char_type c, String_type& s ) { switch( c ) { case '"': s += to_str< String_type >( "\\\"" ); return true; case '\\': s += to_str< String_type >( "\\\\" ); return true; case '\b': s += to_str< String_type >( "\\b" ); return true; case '\f': s += to_str< String_type >( "\\f" ); return true; case '\n': s += to_str< String_type >( "\\n" ); return true; case '\r': s += to_str< String_type >( "\\r" ); return true; case '\t': s += to_str< String_type >( "\\t" ); return true; } return false; } template< class String_type > String_type add_esc_chars( const String_type& s ) { typedef typename String_type::const_iterator Iter_type; typedef typename String_type::value_type Char_type; String_type result; const Iter_type end( s.end() ); for( Iter_type i = s.begin(); i != end; ++i ) { const Char_type c( *i ); if( add_esc_char( c, result ) ) continue; const wint_t unsigned_c( ( c >= 0 ) ? c : 256 + c ); if( iswprint( unsigned_c ) ) { result += c; } else { result += non_printable_to_string< String_type >( unsigned_c ); } } return result; } // this class generates the JSON text, // it keeps track of the indentation level etc. // template< class Value_type, class Ostream_type > class Generator { typedef typename Value_type::Config_type Config_type; typedef typename Config_type::String_type String_type; typedef typename Config_type::Object_type Object_type; typedef typename Config_type::Array_type Array_type; typedef typename String_type::value_type Char_type; typedef typename Object_type::value_type Obj_member_type; public: Generator( const Value_type& value, Ostream_type& os, bool pretty ) : os_( os ) , indentation_level_( 0 ) , pretty_( pretty ) { output( value ); } private: void output( const Value_type& value ) { switch( value.type() ) { case obj_type: output( value.get_obj() ); break; case array_type: output( value.get_array() ); break; case str_type: output( value.get_str() ); break; case bool_type: output( value.get_bool() ); break; case int_type: output_int( value ); break; /// Bitcoin: Added std::fixed and changed precision from 16 to 8 case real_type: os_ << std::showpoint << std::fixed << std::setprecision(8) << value.get_real(); break; case null_type: os_ << "null"; break; default: assert( false ); } } void output( const Object_type& obj ) { output_array_or_obj( obj, '{', '}' ); } void output( const Array_type& arr ) { output_array_or_obj( arr, '[', ']' ); } void output( const Obj_member_type& member ) { output( Config_type::get_name( member ) ); space(); os_ << ':'; space(); output( Config_type::get_value( member ) ); } void output_int( const Value_type& value ) { if( value.is_uint64() ) { os_ << value.get_uint64(); } else { os_ << value.get_int64(); } } void output( const String_type& s ) { os_ << '"' << add_esc_chars( s ) << '"'; } void output( bool b ) { os_ << to_str< String_type >( b ? "true" : "false" ); } template< class T > void output_array_or_obj( const T& t, Char_type start_char, Char_type end_char ) { os_ << start_char; new_line(); ++indentation_level_; for( typename T::const_iterator i = t.begin(); i != t.end(); ++i ) { indent(); output( *i ); typename T::const_iterator next = i; if( ++next != t.end()) { os_ << ','; } new_line(); } --indentation_level_; indent(); os_ << end_char; } void indent() { if( !pretty_ ) return; for( int i = 0; i < indentation_level_; ++i ) { os_ << " "; } } void space() { if( pretty_ ) os_ << ' '; } void new_line() { if( pretty_ ) os_ << '\n'; } Generator& operator=( const Generator& ); // to prevent "assignment operator could not be generated" warning Ostream_type& os_; int indentation_level_; bool pretty_; }; template< class Value_type, class Ostream_type > void write_stream( const Value_type& value, Ostream_type& os, bool pretty ) { Generator< Value_type, Ostream_type >( value, os, pretty ); } template< class Value_type > typename Value_type::String_type write_string( const Value_type& value, bool pretty ) { typedef typename Value_type::String_type::value_type Char_type; std::basic_ostringstream< Char_type > os; write_stream( value, os, pretty ); return os.str(); } } #endif
mit
pbchase/pbchase.github.io
assets/documents/buggy_bar_build_book_1.1.0/final-words.html
11174
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>Chapter 6 Final Words | Buggy Bar Build Book</title> <meta name="description" content="This is how you build a Buggy Bar." /> <meta name="generator" content="bookdown 0.10 and GitBook 2.6.7" /> <meta property="og:title" content="Chapter 6 Final Words | Buggy Bar Build Book" /> <meta property="og:type" content="book" /> <meta property="og:description" content="This is how you build a Buggy Bar." /> <meta name="twitter:card" content="summary" /> <meta name="twitter:title" content="Chapter 6 Final Words | Buggy Bar Build Book" /> <meta name="twitter:description" content="This is how you build a Buggy Bar." /> <meta name="author" content="Philip Chase" /> <meta name="date" content="2019-05-14" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" /> <link rel="prev" href="applications.html"> <link rel="next" href="references.html"> <script src="libs/jquery-2.2.3/jquery.min.js"></script> <link href="libs/gitbook-2.6.7/css/style.css" rel="stylesheet" /> <link href="libs/gitbook-2.6.7/css/plugin-table.css" rel="stylesheet" /> <link href="libs/gitbook-2.6.7/css/plugin-bookdown.css" rel="stylesheet" /> <link href="libs/gitbook-2.6.7/css/plugin-highlight.css" rel="stylesheet" /> <link href="libs/gitbook-2.6.7/css/plugin-search.css" rel="stylesheet" /> <link href="libs/gitbook-2.6.7/css/plugin-fontsettings.css" rel="stylesheet" /> <style type="text/css"> a.sourceLine { display: inline-block; line-height: 1.25; } a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; } a.sourceLine:empty { height: 1.2em; } .sourceCode { overflow: visible; } code.sourceCode { white-space: pre; position: relative; } div.sourceCode { margin: 1em 0; } pre.sourceCode { margin: 0; } @media screen { div.sourceCode { overflow: auto; } } @media print { code.sourceCode { white-space: pre-wrap; } a.sourceLine { text-indent: -1em; padding-left: 1em; } } pre.numberSource a.sourceLine { position: relative; left: -4em; } pre.numberSource a.sourceLine::before { content: attr(title); position: relative; left: -1em; text-align: right; vertical-align: baseline; border: none; pointer-events: all; display: inline-block; -webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; padding: 0 4px; width: 4em; color: #aaaaaa; } pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; } div.sourceCode { } @media screen { a.sourceLine::before { text-decoration: underline; } } code span.al { color: #ff0000; font-weight: bold; } /* Alert */ code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ code span.at { color: #7d9029; } /* Attribute */ code span.bn { color: #40a070; } /* BaseN */ code span.bu { } /* BuiltIn */ code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ code span.ch { color: #4070a0; } /* Char */ code span.cn { color: #880000; } /* Constant */ code span.co { color: #60a0b0; font-style: italic; } /* Comment */ code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ code span.do { color: #ba2121; font-style: italic; } /* Documentation */ code span.dt { color: #902000; } /* DataType */ code span.dv { color: #40a070; } /* DecVal */ code span.er { color: #ff0000; font-weight: bold; } /* Error */ code span.ex { } /* Extension */ code span.fl { color: #40a070; } /* Float */ code span.fu { color: #06287e; } /* Function */ code span.im { } /* Import */ code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */ code span.kw { color: #007020; font-weight: bold; } /* Keyword */ code span.op { color: #666666; } /* Operator */ code span.ot { color: #007020; } /* Other */ code span.pp { color: #bc7a00; } /* Preprocessor */ code span.sc { color: #4070a0; } /* SpecialChar */ code span.ss { color: #bb6688; } /* SpecialString */ code span.st { color: #4070a0; } /* String */ code span.va { color: #19177c; } /* Variable */ code span.vs { color: #4070a0; } /* VerbatimString */ code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ </style> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div class="book without-animation with-summary font-size-2 font-family-1" data-basepath="."> <div class="book-summary"> <nav role="navigation"> <ul class="summary"> <li><a href="./">A Minimal Book Example</a></li> <li class="divider"></li> <li class="chapter" data-level="1" data-path="index.html"><a href="index.html"><i class="fa fa-check"></i><b>1</b> Buggy Bar Build Instructions</a><ul> <li class="chapter" data-level="1.1" data-path="index.html"><a href="index.html#overview"><i class="fa fa-check"></i><b>1.1</b> Overview</a></li> <li class="chapter" data-level="1.2" data-path="index.html"><a href="index.html#bill-of-materials"><i class="fa fa-check"></i><b>1.2</b> Bill of materials</a></li> <li class="chapter" data-level="1.3" data-path="index.html"><a href="index.html#tools-required"><i class="fa fa-check"></i><b>1.3</b> Tools required</a></li> <li class="chapter" data-level="1.4" data-path="index.html"><a href="index.html#component-construction"><i class="fa fa-check"></i><b>1.4</b> Component construction</a><ul> <li class="chapter" data-level="1.4.1" data-path="index.html"><a href="index.html#trim-line"><i class="fa fa-check"></i><b>1.4.1</b> Trim Line</a></li> <li class="chapter" data-level="1.4.2" data-path="index.html"><a href="index.html#cleat-jacket"><i class="fa fa-check"></i><b>1.4.2</b> Cleat Jacket</a></li> <li class="chapter" data-level="1.4.3" data-path="index.html"><a href="index.html#separation-block-and-low-friction-ring"><i class="fa fa-check"></i><b>1.4.3</b> Separation block and low friction ring</a></li> <li class="chapter" data-level="1.4.4" data-path="index.html"><a href="index.html#flag-line"><i class="fa fa-check"></i><b>1.4.4</b> Flag line</a></li> <li class="chapter" data-level="1.4.5" data-path="index.html"><a href="index.html#stub-line"><i class="fa fa-check"></i><b>1.4.5</b> Stub line</a></li> <li class="chapter" data-level="1.4.6" data-path="index.html"><a href="index.html#bar-end-loops"><i class="fa fa-check"></i><b>1.4.6</b> Bar End Loops</a></li> <li class="chapter" data-level="1.4.7" data-path="index.html"><a href="index.html#steering-lines"><i class="fa fa-check"></i><b>1.4.7</b> Steering Lines</a></li> </ul></li> <li class="chapter" data-level="1.5" data-path="index.html"><a href="index.html#assembly"><i class="fa fa-check"></i><b>1.5</b> Assembly</a><ul> <li class="chapter" data-level="1.5.1" data-path="index.html"><a href="index.html#bar-assembly-and-threading-line"><i class="fa fa-check"></i><b>1.5.1</b> Bar assembly and threading line</a></li> <li class="chapter" data-level="1.5.2" data-path="index.html"><a href="index.html#attaching-the-flying-lines"><i class="fa fa-check"></i><b>1.5.2</b> Attaching the flying lines</a></li> <li class="chapter" data-level="1.5.3" data-path="index.html"><a href="index.html#bar-end-loops-1"><i class="fa fa-check"></i><b>1.5.3</b> Bar End Loops</a></li> <li class="chapter" data-level="1.5.4" data-path="index.html"><a href="index.html#steering-line-leaders"><i class="fa fa-check"></i><b>1.5.4</b> Steering line leaders</a></li> </ul></li> <li class="chapter" data-level="1.6" data-path="index.html"><a href="index.html#adjustment"><i class="fa fa-check"></i><b>1.6</b> Adjustment</a></li> </ul></li> <li class="chapter" data-level="2" data-path="intro.html"><a href="intro.html"><i class="fa fa-check"></i><b>2</b> Introduction</a></li> <li class="chapter" data-level="3" data-path="literature.html"><a href="literature.html"><i class="fa fa-check"></i><b>3</b> Literature</a></li> <li class="chapter" data-level="4" data-path="methods.html"><a href="methods.html"><i class="fa fa-check"></i><b>4</b> Methods</a></li> <li class="chapter" data-level="5" data-path="applications.html"><a href="applications.html"><i class="fa fa-check"></i><b>5</b> Applications</a><ul> <li class="chapter" data-level="5.1" data-path="applications.html"><a href="applications.html#example-one"><i class="fa fa-check"></i><b>5.1</b> Example one</a></li> <li class="chapter" data-level="5.2" data-path="applications.html"><a href="applications.html#example-two"><i class="fa fa-check"></i><b>5.2</b> Example two</a></li> </ul></li> <li class="chapter" data-level="6" data-path="final-words.html"><a href="final-words.html"><i class="fa fa-check"></i><b>6</b> Final Words</a></li> <li class="chapter" data-level="" data-path="references.html"><a href="references.html"><i class="fa fa-check"></i>References</a></li> <li class="divider"></li> <li><a href="https://github.com/rstudio/bookdown" target="blank">Published with bookdown</a></li> </ul> </nav> </div> <div class="book-body"> <div class="body-inner"> <div class="book-header" role="navigation"> <h1> <i class="fa fa-circle-o-notch fa-spin"></i><a href="./">Buggy Bar Build Book</a> </h1> </div> <div class="page-wrapper" tabindex="-1" role="main"> <div class="page-inner"> <section class="normal" id="section-"> <div id="final-words" class="section level1"> <h1><span class="header-section-number">Chapter 6</span> Final Words</h1> <p>We have finished a nice book.</p> </div> </section> </div> </div> </div> <a href="applications.html" class="navigation navigation-prev " aria-label="Previous page"><i class="fa fa-angle-left"></i></a> <a href="references.html" class="navigation navigation-next " aria-label="Next page"><i class="fa fa-angle-right"></i></a> </div> </div> <script src="libs/gitbook-2.6.7/js/app.min.js"></script> <script src="libs/gitbook-2.6.7/js/lunr.js"></script> <script src="libs/gitbook-2.6.7/js/plugin-search.js"></script> <script src="libs/gitbook-2.6.7/js/plugin-sharing.js"></script> <script src="libs/gitbook-2.6.7/js/plugin-fontsettings.js"></script> <script src="libs/gitbook-2.6.7/js/plugin-bookdown.js"></script> <script src="libs/gitbook-2.6.7/js/jquery.highlight.js"></script> <script> gitbook.require(["gitbook"], function(gitbook) { gitbook.start({ "sharing": { "github": false, "facebook": true, "twitter": true, "google": false, "linkedin": false, "weibo": false, "instapaper": false, "vk": false, "all": ["facebook", "google", "twitter", "linkedin", "weibo", "instapaper"] }, "fontsettings": { "theme": "white", "family": "sans", "size": 2 }, "edit": { "link": null, "text": null }, "history": { "link": null, "text": null }, "download": ["buggy_bar_build_book.pdf", "buggy_bar_build_book.epub"], "toc": { "collapse": "subsection" } }); }); </script> </body> </html>
mit
jstarc/deep_reasoning
generative_alg.py
12160
import os import load_data import numpy as np from keras.backend import theano_backend as K from keras.callbacks import ModelCheckpoint, EarlyStopping from keras.utils.generic_utils import Progbar from keras.callbacks import Callback import generative_models as gm from common import CsvHistory from common import merge_result_batches import adverse_models as am from collections import Counter from scipy.stats import entropy def train(train, dev, model, model_dir, batch_size, glove, beam_size, samples_per_epoch, val_samples, cmodel, epochs): if not os.path.exists(model_dir): os.makedirs(model_dir) hypo_len = model.get_layer('hypo_input').input_shape[1] -1 ne = model.get_layer('noise_embeddings') vae = model.get_layer('vae_output') g_train = train_generator(train, batch_size, hypo_len, 'class_input' in model.input_names, ne, vae) saver = ModelCheckpoint(model_dir + '/weights.hdf5', monitor = 'hypo_loss', mode = 'min', save_best_only = True) #saver = ModelCheckpoint(model_dir + '/weights{epoch:02d}.hdf5') #es = EarlyStopping(patience = 4, monitor = 'hypo_loss', mode = 'min') csv = CsvHistory(model_dir + '/history.csv') gtest = gm.gen_test(model, glove, batch_size) noise_size = ne.output_shape[-1] if ne else model.get_layer('expansion').input_shape[-1] cb = ValidateGen(dev, gtest, beam_size, hypo_len, val_samples, noise_size, glove, cmodel, True, True) hist = model.fit_generator(g_train, samples_per_epoch = samples_per_epoch, nb_epoch = epochs, callbacks = [cb, saver, csv]) return hist def train_generator(train, batch_size, hypo_len, cinput, ninput, vae): while True: mb = load_data.get_minibatches_idx(len(train[0]), batch_size, shuffle=True) for i, train_index in mb: if len(train_index) != batch_size: continue padded_p = train[0][train_index] padded_h = train[1][train_index] label = train[2][train_index] hypo_input = np.concatenate([np.zeros((batch_size, 1)), padded_h], axis = 1) train_input = np.concatenate([padded_h, np.zeros((batch_size, 1))], axis = 1) inputs = [padded_p, hypo_input] + ([train_index[:, None]] if ninput else []) + [train_input] if cinput: inputs.append(label) outputs = [np.ones((batch_size, hypo_len + 1, 1))] if vae: outputs += [np.zeros(batch_size)] yield (inputs, outputs) def generative_predict_beam(test_model, premises, noise_batch, class_indices, return_best, hypo_len): core_model, premise_func, noise_func = test_model version = int(core_model.name[-1]) batch_size = core_model.input_layers[0].input_shape[0] beam_size = batch_size / len(premises) dup_premises = np.repeat(premises, beam_size, axis = 0) premise = premise_func(dup_premises) if version != 9 else None class_input = np.repeat(class_indices, beam_size, axis = 0) embed_vec = np.repeat(noise_batch, beam_size, axis = 0) if version == 8: noise = noise_func(embed_vec, class_input) elif version == 6 or version == 7: noise = noise_func(embed_vec[:,-1,:], class_input) elif version == 9: noise = noise_func(embed_vec, class_input, dup_premises) elif version == 5: noise = noise_func(embed_vec) core_model.reset_states() core_model.get_layer('attention').set_state(noise) word_input = np.zeros((batch_size, 1)) result_probs = np.zeros(batch_size) debug_probs = np.zeros((hypo_len, batch_size)) lengths = np.zeros(batch_size) words = None probs = None for i in range(hypo_len): data = [premise, word_input, noise, np.zeros((batch_size,1))] if version == 9: data = data[1:] preds = core_model.predict_on_batch(data) preds = np.log(preds) split_preds = np.array(np.split(preds, len(premises))) if probs is None: if beam_size == 1: word_input = np.argmax(split_preds[:, 0, 0], axis = 1)[:,None] else: word_input = np.argpartition(-split_preds[:, 0, 0], beam_size)[:,:beam_size] probs = split_preds[:,0,0][np.arange(len(premises))[:, np.newaxis],[word_input]].ravel() word_input= word_input.ravel()[:,None] words = np.array(word_input) debug_probs[0] = probs else: split_cprobs = (preds[:,-1,:] + probs[:, None]).reshape((len(premises), -1)) if beam_size == 1: max_indices = np.argmax(split_cprobs, axis = 1)[:,None] else: max_indices = np.argpartition(-split_cprobs, beam_size)[:,:beam_size] probs = split_cprobs[np.arange(len(premises))[:, np.newaxis],[max_indices]].ravel() word_input = (max_indices % preds.shape[-1]).ravel()[:,None] state_indices = (max_indices / preds.shape[-1]) + np.arange(0, batch_size, beam_size)[:, None] state_indices = state_indices.ravel() shuffle_states(core_model, state_indices) words = np.concatenate([words[state_indices], word_input], axis = -1) debug_probs = debug_probs[:, state_indices] debug_probs[i] = probs - np.sum(debug_probs, axis = 0) lengths += 1 * (word_input[:,0] > 0).astype('int') if (np.sum(word_input) == 0): words = np.concatenate([words, np.zeros((batch_size, hypo_len - words.shape[1]))], axis = -1) break result_probs = probs / -lengths if return_best: best_ind = np.argmin(np.array(np.split(result_probs, len(premises))), axis =1) + np.arange(0, batch_size, beam_size) return words[best_ind], result_probs[best_ind] else: return words, result_probs, debug_probs def shuffle_states(graph_model, indices): for l in graph_model.layers: if getattr(l, 'stateful', False): for s in l.states: K.set_value(s, s.get_value()[indices]) def val_generator(dev, gen_test, beam_size, hypo_len, noise_size): batch_size = gen_test[0].input_layers[0].input_shape[0] per_batch = batch_size / beam_size while True: mb = load_data.get_minibatches_idx(len(dev[0]), per_batch, shuffle=False) for i, train_index in mb: if len(train_index) != per_batch: continue premises = dev[0][train_index] noise_input = np.random.normal(scale=0.11, size=(per_batch, 1, noise_size)) class_indices = dev[2][train_index] words, loss = generative_predict_beam(gen_test, premises, noise_input, class_indices, True, hypo_len) yield premises, words, loss, noise_input, class_indices def single_generate(premise, label, gen_test, beam_size, hypo_len, noise_size, noise_input = None): batch_size = gen_test[0].input_layers[0].input_shape[0] per_batch = batch_size / beam_size premises = [premise] * per_batch if noise_input is None: noise_input = np.random.normal(scale=0.11, size=(per_batch, 1, noise_size)) class_indices = np.ones(per_batch) * label class_indices = load_data.convert_to_one_hot(class_indices, 3) words, loss = generative_predict_beam(gen_test, premises, noise_input, class_indices, True, hypo_len) return words def validate(dev, gen_test, beam_size, hypo_len, samples, noise_size, glove, cmodel = None, adverse = False, diverse = False): vgen = val_generator(dev, gen_test, beam_size, hypo_len, noise_size) p = Progbar(samples) batchez = [] while p.seen_so_far < samples: batch = next(vgen) preplexity = np.mean(np.power(2, batch[2])) loss = np.mean(batch[2]) losses = [('hypo_loss',loss),('perplexity', preplexity)] if cmodel is not None: ceval = cmodel.evaluate([batch[0], batch[1]], batch[4], verbose = 0) losses += [('class_loss', ceval[0]), ('class_acc', ceval[1])] probs = cmodel.predict([batch[0], batch[1]], verbose = 0) losses += [('class_entropy', np.mean(-np.sum(probs * np.log(probs), axis=1)))] p.add(len(batch[0]), losses) batchez.append(batch) batchez = merge_result_batches(batchez) res = {} if adverse: val_loss = adverse_validation(dev, batchez, glove) print 'adverse_loss:', val_loss res['adverse_loss'] = val_loss if diverse: div, _, _, _ = diversity(dev, gen_test, beam_size, hypo_len, noise_size, 64, 32) res['diversity'] = div print for val in p.unique_values: arr = p.sum_values[val] res[val] = arr[0] / arr[1] return res def adverse_validation(dev, batchez, glove): samples = len(batchez[1]) discriminator = am.discriminator(glove, 50) ad_model = am.adverse_model(discriminator) res = ad_model.fit([dev[1][:samples], batchez[1]], np.zeros(samples), validation_split=0.1, verbose = 0, nb_epoch = 20, callbacks = [EarlyStopping(patience=2)]) return np.min(res.history['val_loss']) def diversity(dev, gen_test, beam_size, hypo_len, noise_size, per_premise, samples): step = len(dev[0]) / samples sind = [i * step for i in range(samples)] p = Progbar(per_premise * samples) for i in sind: hypos = [] unique_words = [] hypo_list = [] premise = dev[0][i] prem_list = set(cut_zeros(list(premise))) while len(hypos) < per_premise: label = np.argmax(dev[2][i]) words = single_generate(premise, label, gen_test, beam_size, hypo_len, noise_size) hypos += [str(ex) for ex in words] unique_words += [int(w) for ex in words for w in ex if w > 0] hypo_list += [set(cut_zeros(list(ex))) for ex in words] jacks = [] prem_jacks = [] for u in range(len(hypo_list)): sim_prem = len(hypo_list[u] & prem_list)/float(len(hypo_list[u] | prem_list)) prem_jacks.append(sim_prem) for v in range(u+1, len(hypo_list)): sim = len(hypo_list[u] & hypo_list[v])/float(len(hypo_list[u] | hypo_list[v])) jacks.append(sim) avg_dist_hypo = 1 - np.mean(jacks) avg_dist_prem = 1 - np.mean(prem_jacks) d = entropy(Counter(hypos).values()) w = entropy(Counter(unique_words).values()) p.add(len(hypos), [('diversity', d),('word_entropy', w),('avg_dist_hypo', avg_dist_hypo), ('avg_dist_prem', avg_dist_prem)]) arrd = p.sum_values['diversity'] arrw = p.sum_values['word_entropy'] arrj = p.sum_values['avg_dist_hypo'] arrp = p.sum_values['avg_dist_prem'] return arrd[0] / arrd[1], arrw[0] / arrw[1], arrj[0] / arrj[1], arrp[0] / arrp[1] def cut_zeros(list): return [a for a in list if a > 0] class ValidateGen(Callback): def __init__(self, dev, gen_test, beam_size, hypo_len, samples, noise_size, glove, cmodel, adverse, diverse): self.dev = dev self.gen_test=gen_test self.beam_size = beam_size self.hypo_len = hypo_len self.samples = samples self.noise_size = noise_size self.cmodel= cmodel self.glove = glove self.adverse = adverse self.diverse = diverse def on_epoch_end(self, epoch, logs={}): gm.update_gen_weights(self.gen_test[0], self.model) val_log = validate(self.dev, self.gen_test, self.beam_size, self.hypo_len, self.samples, self.noise_size, self.glove, self.cmodel, self.adverse, self.diverse) logs.update(val_log)
mit
HynesIP/hello.js
demos/instagram.html
1727
<!DOCTYPE html> <link rel="stylesheet" href="/_packages/document.css"></script> <script src="/_packages/document.js"></script> <script src="client_ids.js"></script> <script src="../src/hello.js"></script> <script src="../src/modules/instagram.js"></script> <title>HelloJS and Instagram</title> <h1>HelloJS and Instagram</h1> <button id='instagram' onclick="getPhotos('instagram')">Get instagram photos</button> <div id="result"></div> <button id="more" style="display:none;">Load more</button> <p>The button above call this function below, like so... <code>getPhotos('instagram')</code></p> <script class="pre"> function getPhotos(network){ hello(network).login().on('success', function(r){ // Get Profile hello( network ).api('me', function(p){ document.getElementById( network ).innerHTML = "<img src='"+ p.thumbnail + "' width=24/>Connected to "+ r.network+" as " + p.name; }); // Get user photos hello( network ).api('me/photos', function(r, next){ for(var i=0;i<r.data.length;i++){ var img = document.createElement('img'); img.title = r.data[i].name; img.src=r.data[i].thumbnail; document.getElementById('result').appendChild(img); } document.getElementById('more').style.display = next ? 'block' : 'none'; if(next){ more.onclick = function(){next()}; } }); }).on('error', function(e){ log("Could not signin" + e.error.message ); }); } </script> <p>Set up your client id</p> <script class="pre"> hello.init({ instagram : INSTAGRAM_CLIENT_ID },{ scope : 'photos', redirect_uri:'../redirect.html' }); </script> <script> function log(str){ console.log(str); document.getElementById('result').appendChild(document.createTextNode(str)); } </script>
mit
vineetreddyrajula/pharo
src/OpalCompiler-Core.package/OCASTSemanticCleaner.class/README.md
105
I am cleaning the semantic analysis of the AST. -> scopes of Blocks and Methpd -> binding from Variables
mit
aleph3d/MiniMediaEducation
MasterServer/MSmmc-ps/plugins/plg-template/lib/xtemplate.class.php
35089
<?php // FILE: xtemplate.class (part of MiniMediaEducation, https://github.com/aleph3d/MiniMediaEducation.git) // TYPE: funciton/class Library (PHP5) // LICENSE: BSD and LGPL ////// Copyright (c) 2000-2001 Barnab�s Debreceni [[email protected]] XTemplate ////// Copyright (c) 2002-2007 Jeremy Coates [[email protected]] XTemplate & CachingXTemplate // When developing uncomment the line below, re-comment before making public //error_reporting(E_ALL); /** * XTemplate PHP templating engine * * @package XTemplate * @author Barnabas Debreceni [[email protected]] * @copyright Barnabas Debreceni 2000-2001 * @author Jeremy Coates [[email protected]] * @copyright Jeremy Coates 2002-2007 * @see license.txt LGPL / BSD license * @since PHP 5 * @link $HeadURL: https://xtpl.svn.sourceforge.net/svnroot/xtpl/trunk/xtemplate.class.php $ * @version $Id: xtemplate.class.php 21 2007-05-29 18:01:15Z cocomp $ * * * XTemplate class - http://www.phpxtemplate.org/ (x)html / xml generation with templates - fast & easy * Latest stable & Subversion versions available @ http://sourceforge.net/projects/xtpl/ * License: LGPL / BSD - see license.txt * Changelog: see changelog.txt */ proCheck() or die(); class XTemplate { /** * Properties */ /** * Raw contents of the template file * * @access public * @var string */ public $filecontents = ''; /** * Unparsed blocks * * @access public * @var array */ public $blocks = array(); /** * Parsed blocks * * @var unknown_type */ public $parsed_blocks = array(); /** * Preparsed blocks (for file includes) * * @access public * @var array */ public $preparsed_blocks = array(); /** * Block parsing order for recursive parsing * (Sometimes reverse :) * * @access public * @var array */ public $block_parse_order = array(); /** * Store sub-block names * (For fast resetting) * * @access public * @var array */ public $sub_blocks = array(); /** * Variables array * * @access public * @var array */ public $vars = array(); /** * File variables array * * @access public * @var array */ public $filevars = array(); /** * Filevars' parent block * * @access public * @var array */ public $filevar_parent = array(); /** * File caching during duration of script * e.g. files only cached to speed {FILE "filename"} repeats * * @access public * @var array */ public $filecache = array(); /** * Location of template files * * @access public * @var string */ public $tpldir = ''; /** * Filenames lookup table * * @access public * @var null */ public $files = null; /** * Template filename * * @access public * @var string */ public $filename = ''; // moved to setup method so uses the tag_start & end_delims /** * RegEx for file includes * * "/\{FILE\s*\"([^\"]+)\"\s*\}/m"; * * @access public * @var string */ public $file_delim = ''; /** * RegEx for file include variable * * "/\{FILE\s*\{([A-Za-z0-9\._]+?)\}\s*\}/m"; * * @access public * @var string */ public $filevar_delim = ''; /** * RegEx for file includes with newlines * * "/^\s*\{FILE\s*\{([A-Za-z0-9\._]+?)\}\s*\}\s*\n/m"; * * @access public * @var string */ public $filevar_delim_nl = ''; /** * Template block start delimiter * * @access public * @var string */ public $block_start_delim = '<!-- '; /** * Template block end delimiter * * @access public * @var string */ public $block_end_delim = '-->'; /** * Template block start word * * @access public * @var string */ public $block_start_word = 'BEGIN:'; /** * Template block end word * * The last 3 properties and this make the delimiters look like: * @example <!-- BEGIN: block_name --> * if you use the default syntax. * * @access public * @var string */ public $block_end_word = 'END:'; /** * Template tag start delimiter * * This makes the delimiters look like: * @example {tagname} * if you use the default syntax. * * @access public * @var string */ public $tag_start_delim = '{'; /** * Template tag end delimiter * * This makes the delimiters look like: * @example {tagname} * if you use the default syntax. * * @access public * @var string */ public $tag_end_delim = '}'; /* this makes the delimiters look like: {tagname} if you use my syntax. */ /** * Regular expression element for comments within tags and blocks * * @example {tagname#My Comment} * @example {tagname #My Comment} * @example <!-- BEGIN: blockname#My Comment --> * @example <!-- BEGIN: blockname #My Comment --> * * @access public * @var string */ public $comment_preg = '( ?#.*?)?'; /** * Default main template block name * * @access public * @var string */ public $mainblock = 'main'; /** * Script output type * * @access public * @var string */ public $output_type = 'HTML'; /** * Debug mode * * @access public * @var boolean */ public $debug = false; /** * Null string for unassigned vars * * @access protected * @var array */ protected $_null_string = array('' => ''); /** * Null string for unassigned blocks * * @access protected * @var array */ protected $_null_block = array('' => ''); /** * Errors * * @access protected * @var string */ protected $_error = ''; /** * Auto-reset sub blocks * * @access protected * @var boolean */ protected $_autoreset = true; /** * Set to FALSE to generate errors if a non-existant blocks is referenced * * @author NW * @since 2002/10/17 * @access protected * @var boolean */ protected $_ignore_missing_blocks = true; /** * PHP 5 Constructor - Instantiate the object * * @param string $file Template file to work on * @param string/array $tpldir Location of template files (useful for keeping files outside web server root) * @param array $files Filenames lookup * @param string $mainblock Name of main block in the template * @param boolean $autosetup If true, run setup() as part of constuctor * @return XTemplate */ public function __construct($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true) { $this->restart($file, $tpldir, $files, $mainblock, $autosetup, $this->tag_start_delim, $this->tag_end_delim); } /** * PHP 4 Constructor - Instantiate the object * * @deprecated Use PHP 5 constructor instead * @param string $file Template file to work on * @param string/array $tpldir Location of template files (useful for keeping files outside web server root) * @param array $files Filenames lookup * @param string $mainblock Name of main block in the template * @param boolean $autosetup If true, run setup() as part of constuctor * @return XTemplate */ public function XTemplate ($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true) { assert('Deprecated - use PHP 5 constructor'); } /***************************************************************************/ /***[ public stuff ]********************************************************/ /***************************************************************************/ /** * Restart the class - allows one instantiation with several files processed by restarting * e.g. $xtpl = new XTemplate('file1.xtpl'); * $xtpl->parse('main'); * $xtpl->out('main'); * $xtpl->restart('file2.xtpl'); * $xtpl->parse('main'); * $xtpl->out('main'); * (Added in response to sf:641407 feature request) * * @param string $file Template file to work on * @param string/array $tpldir Location of template files * @param array $files Filenames lookup * @param string $mainblock Name of main block in the template * @param boolean $autosetup If true, run setup() as part of restarting * @param string $tag_start { * @param string $tag_end } */ public function restart ($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true, $tag_start = '{', $tag_end = '}') { $this->filename = $file; // From SF Feature request 1202027 // Kenneth Kalmer $this->tpldir = $tpldir; if (defined('XTPL_DIR') && empty($this->tpldir)) { $this->tpldir = XTPL_DIR; } if (is_array($files)) { $this->files = $files; } $this->mainblock = $mainblock; $this->tag_start_delim = $tag_start; $this->tag_end_delim = $tag_end; // Start with fresh file contents $this->filecontents = ''; // Reset the template arrays $this->blocks = array(); $this->parsed_blocks = array(); $this->preparsed_blocks = array(); $this->block_parse_order = array(); $this->sub_blocks = array(); $this->vars = array(); $this->filevars = array(); $this->filevar_parent = array(); $this->filecache = array(); if ($autosetup) { $this->setup(); } } /** * setup - the elements that were previously in the constructor * * @access public * @param boolean $add_outer If true is passed when called, it adds an outer main block to the file */ public function setup ($add_outer = false) { $this->tag_start_delim = preg_quote($this->tag_start_delim); $this->tag_end_delim = preg_quote($this->tag_end_delim); // Setup the file delimiters // regexp for file includes $this->file_delim = "/" . $this->tag_start_delim . "FILE\s*\"([^\"]+)\"" . $this->comment_preg . $this->tag_end_delim . "/m"; // regexp for file includes $this->filevar_delim = "/" . $this->tag_start_delim . "FILE\s*" . $this->tag_start_delim . "([A-Za-z0-9\._]+?)" . $this->comment_preg . $this->tag_end_delim . $this->comment_preg . $this->tag_end_delim . "/m"; // regexp for file includes w/ newlines $this->filevar_delim_nl = "/^\s*" . $this->tag_start_delim . "FILE\s*" . $this->tag_start_delim . "([A-Za-z0-9\._]+?)" . $this->comment_preg . $this->tag_end_delim . $this->comment_preg . $this->tag_end_delim . "\s*\n/m"; if (empty($this->filecontents)) { // read in template file $this->filecontents = $this->_r_getfile($this->filename); } if ($add_outer) { $this->_add_outer_block(); } // preprocess some stuff $this->blocks = $this->_maketree($this->filecontents, ''); $this->filevar_parent = $this->_store_filevar_parents($this->blocks); $this->scan_globals(); } /** * assign a variable * * @example Simplest case: * @example $xtpl->assign('name', 'value'); * @example {name} in template * * @example Array assign: * @example $xtpl->assign(array('name' => 'value', 'name2' => 'value2')); * @example {name} {name2} in template * * @example Value as array assign: * @example $xtpl->assign('name', array('key' => 'value', 'key2' => 'value2')); * @example {name.key} {name.key2} in template * * @example Reset array: * @example $xtpl->assign('name', array('key' => 'value', 'key2' => 'value2')); * @example // Other code then: * @example $xtpl->assign('name', array('key3' => 'value3'), false); * @example {name.key} {name.key2} {name.key3} in template * * @access public * @param string $name Variable to assign $val to * @param string / array $val Value to assign to $name * @param boolean $reset_array Reset the variable array if $val is an array */ public function assign ($name, $val = '', $reset_array = true) { if (is_array($name)) { foreach ($name as $k => $v) { $this->vars[$k] = $v; } } elseif (is_array($val)) { // Clear the existing values if ($reset_array) { $this->vars[$name] = array(); } foreach ($val as $k => $v) { $this->vars[$name][$k] = $v; } } else { $this->vars[$name] = $val; } } /** * assign a file variable * * @access public * @param string $name Variable to assign $val to * @param string / array $val Values to assign to $name */ public function assign_file ($name, $val = '') { if (is_array($name)) { foreach ($name as $k => $v) { $this->_assign_file_sub($k, $v); } } else { $this->_assign_file_sub($name, $val); } } /** * parse a block * * @access public * @param string $bname Block name to parse */ public function parse ($bname) { if (isset($this->preparsed_blocks[$bname])) { $copy = $this->preparsed_blocks[$bname]; } elseif (isset($this->blocks[$bname])) { $copy = $this->blocks[$bname]; } elseif ($this->_ignore_missing_blocks) { // ------------------------------------------------------ // NW : 17 Oct 2002. Added default of ignore_missing_blocks // to allow for generalised processing where some // blocks may be removed from the HTML without the // processing code needing to be altered. // ------------------------------------------------------ // JRC: 3/1/2003 added set error to ignore missing functionality $this->_set_error("parse: blockname [$bname] does not exist"); return; } else { $this->_set_error("parse: blockname [$bname] does not exist"); } /* from there we should have no more {FILE } directives */ if (!isset($copy)) { die('Block: ' . $bname); } $copy = preg_replace($this->filevar_delim_nl, '', $copy); $var_array = array(); /* find & replace variables+blocks */ preg_match_all("|" . $this->tag_start_delim . "([A-Za-z0-9\._]+?" . $this->comment_preg . ")" . $this->tag_end_delim. "|", $copy, $var_array); $var_array = $var_array[1]; foreach ($var_array as $k => $v) { // Are there any comments in the tags {tag#a comment for documenting the template} $any_comments = explode('#', $v); $v = rtrim($any_comments[0]); if (sizeof($any_comments) > 1) { $comments = $any_comments[1]; } else { $comments = ''; } $sub = explode('.', $v); if ($sub[0] == '_BLOCK_') { unset($sub[0]); $bname2 = implode('.', $sub); // trinary operator eliminates assign error in E_ALL reporting $var = isset($this->parsed_blocks[$bname2]) ? $this->parsed_blocks[$bname2] : null; $nul = (!isset($this->_null_block[$bname2])) ? $this->_null_block[''] : $this->_null_block[$bname2]; if ($var === '') { if ($nul == '') { // ----------------------------------------------------------- // Removed requirement for blocks to be at the start of string // ----------------------------------------------------------- // $copy=preg_replace("/^\s*\{".$v."\}\s*\n*/m","",$copy); // Now blocks don't need to be at the beginning of a line, //$copy=preg_replace("/\s*" . $this->tag_start_delim . $v . $this->tag_end_delim . "\s*\n*/m","",$copy); $copy = preg_replace("|" . $this->tag_start_delim . $v . $this->tag_end_delim . "|m", '', $copy); } else { $copy = preg_replace("|" . $this->tag_start_delim . $v . $this->tag_end_delim . "|m", "$nul", $copy); } } else { //$var = trim($var); switch (true) { case preg_match('/^\n/', $var) && preg_match('/\n$/', $var): $var = substr($var, 1, -1); break; case preg_match('/^\n/', $var): $var = substr($var, 1); break; case preg_match('/\n$/', $var): $var = substr($var, 0, -1); break; } // SF Bug no. 810773 - thanks anonymous $var = str_replace('\\', '\\\\', $var); // Ensure dollars in strings are not evaluated reported by SadGeezer 31/3/04 $var = str_replace('$', '\\$', $var); // Replaced str_replaces with preg_quote //$var = preg_quote($var); $var = str_replace('\\|', '|', $var); $copy = preg_replace("|" . $this->tag_start_delim . $v . $this->tag_end_delim . "|m", "$var", $copy); if (preg_match('/^\n/', $copy) && preg_match('/\n$/', $copy)) { $copy = substr($copy, 1, -1); } } } else { $var = $this->vars; foreach ($sub as $v1) { // NW 4 Oct 2002 - Added isset and is_array check to avoid NOTICE messages // JC 17 Oct 2002 - Changed EMPTY to stlen=0 // if (empty($var[$v1])) { // this line would think that zeros(0) were empty - which is not true if (!isset($var[$v1]) || (!is_array($var[$v1]) && strlen($var[$v1]) == 0)) { // Check for constant, when variable not assigned if (defined($v1)) { $var[$v1] = constant($v1); } else { $var[$v1] = null; } } $var = $var[$v1]; } $nul = (!isset($this->_null_string[$v])) ? ($this->_null_string[""]) : ($this->_null_string[$v]); $var = (!isset($var)) ? $nul : $var; if ($var === '') { // ----------------------------------------------------------- // Removed requriement for blocks to be at the start of string // ----------------------------------------------------------- // $copy=preg_replace("|^\s*\{".$v." ?#?".$comments."\}\s*\n|m","",$copy); $copy = preg_replace("|" . $this->tag_start_delim . $v . "( ?#" . $comments . ")?" . $this->tag_end_delim . "|m", '', $copy); } $var = trim($var); // SF Bug no. 810773 - thanks anonymous $var = str_replace('\\', '\\\\', $var); // Ensure dollars in strings are not evaluated reported by SadGeezer 31/3/04 $var = str_replace('$', '\\$', $var); // Replace str_replaces with preg_quote //$var = preg_quote($var); $var = str_replace('\\|', '|', $var); $copy = preg_replace("|" . $this->tag_start_delim . $v . "( ?#" . $comments . ")?" . $this->tag_end_delim . "|m", "$var", $copy); if (preg_match('/^\n/', $copy) && preg_match('/\n$/', $copy)) { $copy = substr($copy, 1); } } } if (isset($this->parsed_blocks[$bname])) { $this->parsed_blocks[$bname] .= $copy; } else { $this->parsed_blocks[$bname] = $copy; } /* reset sub-blocks */ if ($this->_autoreset && (!empty($this->sub_blocks[$bname]))) { reset($this->sub_blocks[$bname]); foreach ($this->sub_blocks[$bname] as $k => $v) { $this->reset($v); } } } /** * returns the parsed text for a block, including all sub-blocks. * * @access public * @param string $bname Block name to parse */ public function rparse ($bname) { if (!empty($this->sub_blocks[$bname])) { reset($this->sub_blocks[$bname]); foreach ($this->sub_blocks[$bname] as $k => $v) { if (!empty($v)) { $this->rparse($v); } } } $this->parse($bname); } /** * inserts a loop ( call assign & parse ) * * @access public * @param string $bname Block name to assign * @param string $var Variable to assign values to * @param string / array $value Value to assign to $var */ public function insert_loop ($bname, $var, $value = '') { $this->assign($var, $value); $this->parse($bname); } /** * parses a block for every set of data in the values array * * @access public * @param string $bname Block name to loop * @param string $var Variable to assign values to * @param array $values Values to assign to $var */ public function array_loop ($bname, $var, &$values) { if (is_array($values)) { foreach($values as $v) { $this->insert_loop($bname, $var, $v); } } } /** * returns the parsed text for a block * * @access public * @param string $bname Block name to return * @return string */ public function text ($bname = '') { $text = ''; if ($this->debug && $this->output_type == 'HTML') { // JC 20/11/02 echo the template filename if in development as // html comment $text .= '<!-- XTemplate: ' . realpath($this->filename) . " -->\n"; } $bname = !empty($bname) ? $bname : $this->mainblock; $text .= isset($this->parsed_blocks[$bname]) ? $this->parsed_blocks[$bname] : $this->get_error(); return $text; } /** * prints the parsed text * * @access public * @param string $bname Block name to echo out */ public function out ($bname) { $out = $this->text($bname); // $length=strlen($out); //header("Content-Length: ".$length); // TODO: Comment this back in later echo $out; } public function VariableOut ($bname) { $out = $this->text($bname); // $length=strlen($out); //header("Content-Length: ".$length); // TODO: Comment this back in later return $out; } /** * prints the parsed text to a specified file * * @access public * @param string $bname Block name to write out * @param string $fname File name to write to */ public function out_file ($bname, $fname) { if (!empty($bname) && !empty($fname) && is_writeable($fname)) { $fp = fopen($fname, 'w'); fwrite($fp, $this->text($bname)); fclose($fp); } } /** * resets the parsed text * * @access public * @param string $bname Block to reset */ public function reset ($bname) { $this->parsed_blocks[$bname] = ''; } /** * returns true if block was parsed, false if not * * @access public * @param string $bname Block name to test * @return boolean */ public function parsed ($bname) { return (!empty($this->parsed_blocks[$bname])); } /** * sets the string to replace in case the var was not assigned * * @access public * @param string $str Display string for null block * @param string $varname Variable name to apply $str to */ public function set_null_string($str, $varname = '') { $this->_null_string[$varname] = $str; } /** * Backwards compatibility only * * @param string $str * @param string $varname * @deprecated Change to set_null_string to keep in with rest of naming convention */ public function SetNullString ($str, $varname = '') { $this->set_null_string($str, $varname); } /** * sets the string to replace in case the block was not parsed * * @access public * @param string $str Display string for null block * @param string $bname Block name to apply $str to */ public function set_null_block ($str, $bname = '') { $this->_null_block[$bname] = $str; } /** * Backwards compatibility only * * @param string $str * @param string $bname * @deprecated Change to set_null_block to keep in with rest of naming convention */ public function SetNullBlock ($str, $bname = '') { $this->set_null_block($str, $bname); } /** * sets AUTORESET to 1. (default is 1) * if set to 1, parse() automatically resets the parsed blocks' sub blocks * (for multiple level blocks) * * @access public */ public function set_autoreset () { $this->_autoreset = true; } /** * sets AUTORESET to 0. (default is 1) * if set to 1, parse() automatically resets the parsed blocks' sub blocks * (for multiple level blocks) * * @access public */ public function clear_autoreset () { $this->_autoreset = false; } /** * scans global variables and assigns to PHP array * * @access public */ public function scan_globals () { reset($GLOBALS); foreach ($GLOBALS as $k => $v) { $GLOB[$k] = $v; } /** * Access global variables as: * @example {PHP._SERVER.HTTP_HOST} * in your template! */ $this->assign('PHP', $GLOB); } /** * gets error condition / string * * @access public * @return boolean / string */ public function get_error () { // JRC: 3/1/2003 Added ouptut wrapper and detection of output type for error message output $retval = false; if ($this->_error != '') { switch ($this->output_type) { case 'HTML': case 'html': $retval = '<b>[XTemplate]</b><ul>' . nl2br(str_replace('* ', '<li>', str_replace(" *\n", "</li>\n", $this->_error))) . '</ul>'; break; default: $retval = '[XTemplate] ' . str_replace(' *\n', "\n", $this->_error); break; } } return $retval; } /***************************************************************************/ /***[ private stuff ]*******************************************************/ /***************************************************************************/ /** * generates the array containing to-be-parsed stuff: * $blocks["main"],$blocks["main.table"],$blocks["main.table.row"], etc. * also builds the reverse parse order. * * @access public - aiming for private * @param string $con content to be processed * @param string $parentblock name of the parent block in the block hierarchy */ public function _maketree ($con, $parentblock='') { $blocks = array(); $con2 = explode($this->block_start_delim, $con); if (!empty($parentblock)) { $block_names = explode('.', $parentblock); $level = sizeof($block_names); } else { $block_names = array(); $level = 0; } // JRC 06/04/2005 Added block comments (on BEGIN or END) <!-- BEGIN: block_name#Comments placed here --> //$patt = "($this->block_start_word|$this->block_end_word)\s*(\w+)\s*$this->block_end_delim(.*)"; $patt = "(" . $this->block_start_word . "|" . $this->block_end_word . ")\s*(\w+)" . $this->comment_preg . "\s*" . $this->block_end_delim . "(.*)"; foreach($con2 as $k => $v) { $res = array(); if (preg_match_all("/$patt/ims", $v, $res, PREG_SET_ORDER)) { // $res[0][1] = BEGIN or END // $res[0][2] = block name // $res[0][3] = comment // $res[0][4] = kinda content $block_word = $res[0][1]; $block_name = $res[0][2]; $comment = $res[0][3]; $content = $res[0][4]; if (strtoupper($block_word) == $this->block_start_word) { $parent_name = implode('.', $block_names); // add one level - array("main","table","row") $block_names[++$level] = $block_name; // make block name (main.table.row) $cur_block_name=implode('.', $block_names); // build block parsing order (reverse) $this->block_parse_order[] = $cur_block_name; //add contents. trinary operator eliminates assign error in E_ALL reporting $blocks[$cur_block_name] = isset($blocks[$cur_block_name]) ? $blocks[$cur_block_name] . $content : $content; // add {_BLOCK_.blockname} string to parent block $blocks[$parent_name] .= str_replace('\\', '', $this->tag_start_delim) . '_BLOCK_.' . $cur_block_name . str_replace('\\', '', $this->tag_end_delim); // store sub block names for autoresetting and recursive parsing $this->sub_blocks[$parent_name][] = $cur_block_name; // store sub block names for autoresetting $this->sub_blocks[$cur_block_name][] = ''; } else if (strtoupper($block_word) == $this->block_end_word) { unset($block_names[$level--]); $parent_name = implode('.', $block_names); // add rest of block to parent block $blocks[$parent_name] .= $content; } } else { // no block delimiters found // Saves doing multiple implodes - less overhead $tmp = implode('.', $block_names); if ($k) { $blocks[$tmp] .= $this->block_start_delim; } // trinary operator eliminates assign error in E_ALL reporting $blocks[$tmp] = isset($blocks[$tmp]) ? $blocks[$tmp] . $v : $v; } } return $blocks; } /** * Sub processing for assign_file method * * @access private * @param string $name * @param string $val */ private function _assign_file_sub ($name, $val) { if (isset($this->filevar_parent[$name])) { if ($val != '') { $val = $this->_r_getfile($val); foreach($this->filevar_parent[$name] as $parent) { if (isset($this->preparsed_blocks[$parent]) && !isset($this->filevars[$name])) { $copy = $this->preparsed_blocks[$parent]; } elseif (isset($this->blocks[$parent])) { $copy = $this->blocks[$parent]; } $res = array(); preg_match_all($this->filevar_delim, $copy, $res, PREG_SET_ORDER); if (is_array($res) && isset($res[0])) { // Changed as per solution in SF bug ID #1261828 foreach ($res as $v) { // Changed as per solution in SF bug ID #1261828 if ($v[1] == $name) { // Changed as per solution in SF bug ID #1261828 $copy = preg_replace("/" . preg_quote($v[0]) . "/", "$val", $copy); $this->preparsed_blocks = array_merge($this->preparsed_blocks, $this->_maketree($copy, $parent)); $this->filevar_parent = array_merge($this->filevar_parent, $this->_store_filevar_parents($this->preparsed_blocks)); } } } } } } $this->filevars[$name] = $val; } /** * store container block's name for file variables * * @access public - aiming for private * @param array $blocks * @return array */ public function _store_filevar_parents ($blocks){ $parents = array(); foreach ($blocks as $bname => $con) { $res = array(); preg_match_all($this->filevar_delim, $con, $res); foreach ($res[1] as $k => $v) { $parents[$v][] = $bname; } } return $parents; } /** * Set the error string * * @access private * @param string $str */ private function _set_error ($str) { // JRC: 3/1/2003 Made to append the error messages $this->_error .= '* ' . $str . " *\n"; // JRC: 3/1/2003 Removed trigger error, use this externally if you want it eg. trigger_error($xtpl->get_error()) //trigger_error($this->get_error()); } /** * returns the contents of a file * * @access protected * @param string $file * @return string */ protected function _getfile ($file) { if (!isset($file)) { // JC 19/12/02 added $file to error message $this->_set_error('!isset file name!' . $file); return ''; } // check if filename is mapped to other filename if (isset($this->files)) { if (isset($this->files[$file])) { $file = $this->files[$file]; } } // prepend template dir if (!empty($this->tpldir)) { /** * Support hierarchy of file locations to search * * @example Supply array of filepaths when instantiating * First path supplied that has the named file is prioritised * $xtpl = new XTemplate('myfile.xtpl', array('.','/mypath', '/mypath2')); * @since 29/05/2007 */ if (is_array($this->tpldir)) { foreach ($this->tpldir as $dir) { if (is_readable($dir . DIRECTORY_SEPARATOR . $file)) { $file = $dir . DIRECTORY_SEPARATOR . $file; break; } } } else { $file = $this->tpldir. DIRECTORY_SEPARATOR . $file; } } $file_text = ''; if (isset($this->filecache[$file])) { $file_text .= $this->filecache[$file]; if ($this->debug) { $file_text = '<!-- XTemplate debug cached: ' . realpath($file) . ' -->' . "\n" . $file_text; } } else { if (is_file($file) && is_readable($file)) { if (filesize($file)) { if (!($fh = fopen($file, 'r'))) { $this->_set_error('Cannot open file: ' . realpath($file)); return ''; } $file_text .= fread($fh,filesize($file)); fclose($fh); } if ($this->debug) { $file_text = '<!-- XTemplate debug: ' . realpath($file) . ' -->' . "\n" . $file_text; } } elseif (str_replace('.', '', phpversion()) >= '430' && $file_text = @file_get_contents($file, true)) { // Enable use of include path by using file_get_contents // Implemented at suggestion of SF Feature Request ID #1529478 michaelgroh if ($file_text === false) { $this->_set_error("[" . realpath($file) . "] ($file) does not exist"); $file_text = "<b>__XTemplate fatal error: file [$file] does not exist in the include path__</b>"; } elseif ($this->debug) { $file_text = '<!-- XTemplate debug: ' . realpath($file) . ' (via include path) -->' . "\n" . $file_text; } } elseif (!is_file($file)) { // NW 17 Oct 2002 : Added realpath around the file name to identify where the code is searching. $this->_set_error("[" . realpath($file) . "] ($file) does not exist"); $file_text .= "<b>__XTemplate fatal error: file [$file] does not exist__</b>"; } elseif (!is_readable($file)) { $this->_set_error("[" . realpath($file) . "] ($file) is not readable"); $file_text .= "<b>__XTemplate fatal error: file [$file] is not readable__</b>"; } $this->filecache[$file] = $file_text; } return $file_text; } /** * recursively gets the content of a file with {FILE "filename.tpl"} directives * * @access public - aiming for private * @param string $file * @return string */ public function _r_getfile ($file) { $text = $this->_getfile($file); $res = array(); while (preg_match($this->file_delim,$text,$res)) { $text2 = $this->_getfile($res[1]); $text = preg_replace("'".preg_quote($res[0])."'",$text2,$text); } return $text; } /** * add an outer block delimiter set useful for rtfs etc - keeps them editable in word * * @access private */ private function _add_outer_block () { $before = $this->block_start_delim . $this->block_start_word . ' ' . $this->mainblock . ' ' . $this->block_end_delim; $after = $this->block_start_delim . $this->block_end_word . ' ' . $this->mainblock . ' ' . $this->block_end_delim; $this->filecontents = $before . "\n" . $this->filecontents . "\n" . $after; } /** * Debug function - var_dump wrapped in '<pre></pre>' tags * * @access private * @param multiple var_dumps all the supplied arguments */ private function _pre_var_dump ($args) { if ($this->debug) { echo '<pre>'; var_dump(func_get_args()); echo '</pre>'; } } } /* end of XTemplate class. */ ?>
mit
omarramos/sunspot_rails-temp
lib/sunspot/rails/request_lifecycle.rb
1373
module Sunspot #:nodoc: module Rails #:nodoc: # # This module adds an after_filter to ActionController::Base that commits # the Sunspot session if any documents have been added, changed, or removed # in the course of the request. # module RequestLifecycle class <<self def included(base) #:nodoc: subclasses = base.subclasses.map do |subclass| begin subclass.constantize rescue NameError end end.compact loaded_controllers = [base].concat(subclasses) # Depending on how Sunspot::Rails is loaded, there may already be # controllers loaded into memory that subclass this controller. In # this case, since after_filter uses the inheritable_attribute # structure, the already-loaded subclasses don't get the filters. So, # the below ensures that all loaded controllers have the filter. loaded_controllers.each do |controller| controller.after_filter do if Sunspot::Rails.configuration.auto_commit_after_request? Sunspot.commit_if_dirty elsif Sunspot::Rails.configuration.auto_commit_after_delete_request? Sunspot.commit_if_delete_dirty end end end end end end end end
mit
arjunravinarayan/differential-dataflow
tpchlike/src/queries/query08.rs
3553
use timely::dataflow::*; use timely::dataflow::operators::*; use timely::dataflow::operators::probe::Handle as ProbeHandle; use differential_dataflow::AsCollection; use differential_dataflow::operators::*; use differential_dataflow::lattice::Lattice; use differential_dataflow::difference::DiffPair; use ::Collections; use ::types::create_date; // -- $ID$ // -- TPC-H/TPC-R National Market Share Query (Q8) // -- Functional Query Definition // -- Approved February 1998 // :x // :o // select // o_year, // sum(case // when nation = ':1' then volume // else 0 // end) / sum(volume) as mkt_share // from // ( // select // extract(year from o_orderdate) as o_year, // l_extendedprice * (1 - l_discount) as volume, // n2.n_name as nation // from // part, // supplier, // lineitem, // orders, // customer, // nation n1, // nation n2, // region // where // p_partkey = l_partkey // and s_suppkey = l_suppkey // and l_orderkey = o_orderkey // and o_custkey = c_custkey // and c_nationkey = n1.n_nationkey // and n1.n_regionkey = r_regionkey // and r_name = ':2' // and s_nationkey = n2.n_nationkey // and o_orderdate between date '1995-01-01' and date '1996-12-31' // and p_type = ':3' // ) as all_nations // group by // o_year // order by // o_year; // :n -1 fn starts_with(source: &[u8], query: &[u8]) -> bool { source.len() >= query.len() && &source[..query.len()] == query } pub fn query<G: Scope>(collections: &mut Collections<G>) -> ProbeHandle<G::Timestamp> where G::Timestamp: Lattice+Ord { let regions = collections.regions().filter(|r| starts_with(&r.name, b"AMERICA")).map(|r| r.region_key); let nations1 = collections.nations().map(|n| (n.region_key, n.nation_key)).semijoin_u(&regions).map(|x| x.1); let customers = collections.customers().map(|c| (c.nation_key, c.cust_key)).semijoin_u(&nations1).map(|x| x.1); let orders = collections .orders() .flat_map(|o| if create_date(1995,1,1) <= o.order_date && o.order_date <= create_date(1996, 12, 31) { Some((o.cust_key, (o.order_key, o.order_date >> 16))) } else { None } ) .semijoin_u(&customers) .map(|x| x.1); let nations2 = collections.nations.map(|n| (n.nation_key, starts_with(&n.name, b"BRAZIL"))); let suppliers = collections .suppliers() .map(|s| (s.nation_key, s.supp_key)) .join_u(&nations2) .map(|(_, supp_key, is_name)| (supp_key, is_name)); let parts = collections.parts.filter(|p| p.typ.as_str() == "ECONOMY ANODIZED STEEL").map(|p| p.part_key); collections .lineitems() .inner .map(|(l,t,d)| ((l.part_key, (l.supp_key, l.order_key)), t, ((l.extended_price * (100 - l.discount)) as isize / 100) * d)) .as_collection() .semijoin_u(&parts) .map(|(_part_key, (supp_key, order_key))| (order_key, supp_key)) .join_u(&orders) .map(|(_order_key, supp_key, order_date)| (supp_key, order_date)) .join_u(&suppliers) .inner .map(|((_, order_date, is_name), time, price)| (order_date, time, DiffPair::new(if is_name { price } else { 0 }, price))) .as_collection() .count_u() .probe() }
mit