Expand inlineable runtime functions
This commit is contained in:
		
							parent
							
								
									75582f40bf
								
							
						
					
					
						commit
						201f0b286f
					
				| @ -261,41 +261,6 @@ do | |||||||
| 	module.gt = gt | 	module.gt = gt | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| do |  | ||||||
| 	local bnot = {} |  | ||||||
| 
 |  | ||||||
| 	bnot.i32 = bit.bnot |  | ||||||
| 	bnot.i64 = bit.bnot |  | ||||||
| 
 |  | ||||||
| 	module.bnot = bnot |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| do |  | ||||||
| 	local shl = {} |  | ||||||
| 	local shr = {} |  | ||||||
| 	local rotl = {} |  | ||||||
| 	local rotr = {} |  | ||||||
| 
 |  | ||||||
| 	shl.i32 = bit.lshift |  | ||||||
| 	shl.u32 = bit.lshift |  | ||||||
| 	shr.i32 = bit.arshift |  | ||||||
| 	shr.u32 = bit.rshift |  | ||||||
| 	rotl.i32 = bit.rol |  | ||||||
| 	rotr.i32 = bit.ror |  | ||||||
| 
 |  | ||||||
| 	shl.i64 = bit.lshift |  | ||||||
| 	shl.u64 = bit.lshift |  | ||||||
| 	shr.i64 = bit.arshift |  | ||||||
| 	shr.u64 = bit.rshift |  | ||||||
| 	rotl.i64 = bit.rol |  | ||||||
| 	rotr.i64 = bit.ror |  | ||||||
| 
 |  | ||||||
| 	module.shl = shl |  | ||||||
| 	module.shr = shr |  | ||||||
| 	module.rotl = rotl |  | ||||||
| 	module.rotr = rotr |  | ||||||
| end |  | ||||||
| 
 |  | ||||||
| do | do | ||||||
| 	local wrap = {} | 	local wrap = {} | ||||||
| 	local trunc = {} | 	local trunc = {} | ||||||
|  | |||||||
| @ -214,17 +214,18 @@ fn build_func_list(wasm: &Module, type_info: &TypeInfo) -> Vec<FuncData> { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn write_local_operation(head: &str, tail: &str, w: &mut dyn Write) -> Result<()> { | fn write_local_operation(head: &str, tail: &str, w: &mut dyn Write) -> Result<()> { | ||||||
|  | 	write!(w, "local {head}_{tail} = ")?; | ||||||
|  | 
 | ||||||
| 	match (head, tail) { | 	match (head, tail) { | ||||||
| 		("band" | "bor" | "bxor", _) => { | 		("abs" | "ceil" | "floor" | "sqrt" | "min" | "max", _) => write!(w, "math.{head} "), | ||||||
| 			write!(w, "local {head}_{tail} = bit.{head} ") | 		("rem", "i32") => write!(w, "math.fmod "), | ||||||
| 		} | 		("band" | "bor" | "bxor" | "bnot", _) => write!(w, "bit.{head} "), | ||||||
| 		("abs" | "ceil" | "floor" | "sqrt" | "min" | "max", _) => { | 		("shl", _) => write!(w, "bit.lshift "), | ||||||
| 			write!(w, "local {head}_{tail} = math.{head} ") | 		("shr", "i32" | "i64") => write!(w, "bit.arshift "), | ||||||
| 		} | 		("shr", "u32" | "u64") => write!(w, "bit.rshift "), | ||||||
| 		("rem", "i32") => { | 		("rotl", _) => write!(w, "bit.rol "), | ||||||
| 			write!(w, "local {head}_{tail} = math.fmod ") | 		("rotr", _) => write!(w, "bit.ror "), | ||||||
| 		} | 		_ => write!(w, "rt.{head}.{tail} "), | ||||||
| 		_ => write!(w, "local {head}_{tail} = rt.{head}.{tail} "), |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -177,13 +177,8 @@ do | |||||||
| end | end | ||||||
| 
 | 
 | ||||||
| do | do | ||||||
| 	local clz = {} |  | ||||||
| 	local ctz = {} |  | ||||||
| 	local popcnt = {} | 	local popcnt = {} | ||||||
| 
 | 
 | ||||||
| 	clz.i32 = bit32.countlz |  | ||||||
| 	ctz.i32 = bit32.countrz |  | ||||||
| 
 |  | ||||||
| 	function popcnt.i32(num) | 	function popcnt.i32(num) | ||||||
| 		local count = 0 | 		local count = 0 | ||||||
| 
 | 
 | ||||||
| @ -195,8 +190,6 @@ do | |||||||
| 		return count | 		return count | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| 	module.clz = clz |  | ||||||
| 	module.ctz = ctz |  | ||||||
| 	module.popcnt = popcnt | 	module.popcnt = popcnt | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| @ -272,8 +265,6 @@ do | |||||||
| 	local bxor = {} | 	local bxor = {} | ||||||
| 	local bnot = {} | 	local bnot = {} | ||||||
| 
 | 
 | ||||||
| 	bnot.i32 = bit32.bnot |  | ||||||
| 
 |  | ||||||
| 	band.i64 = I64.bit_and | 	band.i64 = I64.bit_and | ||||||
| 	bor.i64 = I64.bit_or | 	bor.i64 = I64.bit_or | ||||||
| 	bxor.i64 = I64.bit_xor | 	bxor.i64 = I64.bit_xor | ||||||
|  | |||||||
| @ -213,14 +213,14 @@ fn build_func_list(wasm: &Module, type_info: &TypeInfo) -> Vec<FuncData> { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn write_local_operation(head: &str, tail: &str, w: &mut dyn Write) -> Result<()> { | fn write_local_operation(head: &str, tail: &str, w: &mut dyn Write) -> Result<()> { | ||||||
|  | 	write!(w, "local {head}_{tail} = ")?; | ||||||
|  | 
 | ||||||
| 	match (head, tail) { | 	match (head, tail) { | ||||||
| 		("band" | "bor" | "bxor", "i32") => { | 		("abs" | "ceil" | "floor" | "sqrt", _) => write!(w, "math.{head} "), | ||||||
| 			write!(w, "local {head}_{tail} = bit32.{head} ") | 		("band" | "bor" | "bxor" | "bnot", "i32") => write!(w, "bit32.{head} "), | ||||||
| 		} | 		("clz", "i32") => write!(w, "bit32.countlz "), | ||||||
| 		("abs" | "ceil" | "floor" | "sqrt", _) => { | 		("ctz", "i32") => write!(w, "bit32.countrz "), | ||||||
| 			write!(w, "local {head}_{tail} = math.{head} ") | 		_ => write!(w, "rt.{head}.{tail} "), | ||||||
| 		} |  | ||||||
| 		_ => write!(w, "local {head}_{tail} = rt.{head}.{tail} "), |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user