Skip to content

Commit

Permalink
Add a null encoding for ireduce.i32.i64.
Browse files Browse the repository at this point in the history
This conversion doesn't require any code, we're just looking at the bits
differently.
  • Loading branch information
Jakob Stoklund Olesen committed Jul 19, 2017
1 parent 13190fd commit 444f955
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions filetests/wasm/conversions.cton
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
; Test code generation for WebAssembly type conversion operators.
test compile

set is_64bit=1
isa intel haswell

function %i32_wrap_i64(i64) -> i32 {
ebb0(v0: i64):
v1 = ireduce.i32 v0
return v1
}
5 changes: 5 additions & 0 deletions lib/cretonne/meta/isa/intel/encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,8 @@
I64.enc(base.bint.i64.b1, *r.urm_abcd(0x0f, 0xb6)) # zext to i64 implicit.
I64.enc(base.bint.i32.b1, *r.urm.rex(0x0f, 0xb6))
I64.enc(base.bint.i32.b1, *r.urm_abcd(0x0f, 0xb6))

# Numerical conversions.

# Converting i64 to i32 is a no-op in 64-bit mode.
I64.enc(base.ireduce.i32.i64, r.null, 0)
4 changes: 4 additions & 0 deletions lib/cretonne/meta/isa/intel/recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ def rex(self, *ops, **kwargs):
return (self.recipes[name], bits)


# A null unary instruction that takes a GPR register. Can be used for identity
# copies and no-op conversions.
null = EncRecipe('null', Unary, size=0, ins=GPR, outs=0, emit='')

# XX /r
rr = TailRecipe(
'rr', Binary, size=1, ins=(GPR, GPR), outs=0,
Expand Down

0 comments on commit 444f955

Please sign in to comment.