Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Linearscan register allocator

NotificationsYou must be signed in to change notification settings

js-js/linearscan.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Linearscan register allocator for javascript

API

// Declare some instructionsvarlinearscan=require('linearscan');functiongp(kind,value){return{kind:kind,group:'gp',value:value};}functionfp(kind,value){return{kind:kind,group:'fp',value:value};}varconfig=linearscan.config.create({// Multiple register groups might be specified, they will be allocated// separatelyregisters:{gp:['rax','rbx','rcx','rdx'],fp:['xmm1','xmm2','xmm3','xmm4']},opcodes:{literal:{// 'any' means either 'register' or 'spill'output:gp('any')},'literal-fp':{output:fp('any')},// Set `branch` to `true` to get links to other regionsif:{branch:true},jump:{branch:true},add:{output:gp('any'),inputs:[gp('any'),gp('any')]},'add-fp':{output:fp('any'),inputs:[fp('any'),fp('any')]},floor:{output:gp('any'),inputs:[fp('any')]},return:{// specify particular register that MUST be used hereinputs:[gp('register','rax')]},'rax-out':{inputs:[],output:gp('register','rax'),spills:[]},'rbx-out':{inputs:[],output:gp('register','rbx'),spills:[]},'rbx-call':{inputs:[],output:gp('register','rbx'),// Scratches are similar to spills, but neither input nor output will// be allocated to this value.scratches:[gp('register','rdx')],spills:[gp('register','rax'),gp('register','rbx'),gp('register','rcx')]},call:{output:gp('register','rax'),// 'register' means just any GP registerinputs:[gp('register'),gp('any')],spills:[gp('register','rax'),gp('register','rbx'),gp('register','rcx'),gp('register','rdx')]}}});// Get pipeline from previous stages of compiler// (see json-pipeline npm module)varpipeline=getPipeline();// Make sure that pipeline is properly indexedpipeline.reindex();varout=linearscan.allocate(pipeline,config);console.log(out.render('printable'));

Will output something like this:

register{%rax=literal1%rbx=literal2%rcx=literal3%rdx=literal4[0]=ls:move%3%rdx=literal5[1]=ls:move[0][3]=ls:move%1[2]=ls:move%2[0]=ls:move%3%rax=call%rdx,%rax%rax=add[3],[3]%rax=add[2],[2]%rax=add[1],[1]%rax=add[0],[0]}

Spill count

out.spillType is the list of spill ranges of following format:{ type: 'register-group', from: index, to: index }.

LICENSE

This software is licensed under the MIT License.

Copyright Fedor Indutny, 2015.

Permission is hereby granted, free of charge, to any person obtaining acopy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and to permitpersons to whom the Software is furnished to do so, subject to thefollowing conditions:

The above copyright notice and this permission notice shall be includedin all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. INNO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OROTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THEUSE OR OTHER DEALINGS IN THE SOFTWARE.

About

Linearscan register allocator

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp