Use ?SHL and ?SHR for 'bsl' and 'bsr'
This commit is contained in:
parent
387fdf5c34
commit
23ccce4c22
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
%% NOTE: When possible deps are referenced by Git ref to ensure consistency between builds.
|
%% NOTE: When possible deps are referenced by Git ref to ensure consistency between builds.
|
||||||
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git",
|
{deps, [ {aebytecode, {git, "https://github.com/aeternity/aebytecode.git",
|
||||||
{ref,"6aec14e"}}}
|
{ref,"720510a"}}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[{<<"aebytecode">>,
|
[{<<"aebytecode">>,
|
||||||
{git,"https://github.com/aeternity/aebytecode.git",
|
{git,"https://github.com/aeternity/aebytecode.git",
|
||||||
{ref,"6aec14e64d9ad4dedad98c64b2c16e30af1ea9ea"}},
|
{ref,"720510a24de32c9bad6486f34ca7babde124bf1e"}},
|
||||||
0}].
|
0}].
|
||||||
|
@ -526,12 +526,9 @@ ast_binop(Op, Ann, {typed, _, A, Type}, B, Icode)
|
|||||||
ast_binop('++', _, A, B, Icode) ->
|
ast_binop('++', _, A, B, Icode) ->
|
||||||
#funcall{ function = #var_ref{ name = {builtin, list_concat} },
|
#funcall{ function = #var_ref{ name = {builtin, list_concat} },
|
||||||
args = [ast_body(A, Icode), ast_body(B, Icode)] };
|
args = [ast_body(A, Icode), ast_body(B, Icode)] };
|
||||||
ast_binop('bsl', _, A, B, Icode) ->
|
%% Bit shift operations takes their arguments backwards!?
|
||||||
#binop{op = '*', left = ast_body(A, Icode),
|
ast_binop(Op, _, A, B, Icode) when Op =:= 'bsl'; Op =:= 'bsr' ->
|
||||||
right = #binop{op = '^', left = {integer, 2}, right = ast_body(B, Icode)}};
|
#binop{op = Op, right = ast_body(A, Icode), left = ast_body(B, Icode)};
|
||||||
ast_binop('bsr', _, A, B, Icode) ->
|
|
||||||
#binop{op = 'div', left = ast_body(A, Icode),
|
|
||||||
right = #binop{op = '^', left = {integer, 2}, right = ast_body(B, Icode)}};
|
|
||||||
ast_binop(Op, _, A, B, Icode) ->
|
ast_binop(Op, _, A, B, Icode) ->
|
||||||
#binop{op = Op, left = ast_body(A, Icode), right = ast_body(B, Icode)}.
|
#binop{op = Op, left = ast_body(A, Icode), right = ast_body(B, Icode)}.
|
||||||
|
|
||||||
|
@ -81,8 +81,9 @@ option_some(X) -> {tuple, [{integer, 1}, X]}.
|
|||||||
-define(EXP(A, B), op('^', A, B)).
|
-define(EXP(A, B), op('^', A, B)).
|
||||||
-define(AND(A, B), op('&&', A, B)).
|
-define(AND(A, B), op('&&', A, B)).
|
||||||
|
|
||||||
-define(BSL(X, B), ?MUL(X, ?EXP(2, ?MUL(B, 8)))).
|
%% Bit shift operations takes their arguments backwards!?
|
||||||
-define(BSR(X, B), ?DIV(X, ?EXP(2, ?MUL(B, 8)))).
|
-define(BSL(X, B), op('bsl', ?MUL(B, 8), X)).
|
||||||
|
-define(BSR(X, B), op('bsr', ?MUL(B, 8), X)).
|
||||||
|
|
||||||
op(Op, A, B) -> {binop, Op, operand(A), operand(B)}.
|
op(Op, A, B) -> {binop, Op, operand(A), operand(B)}.
|
||||||
|
|
||||||
|
@ -562,6 +562,8 @@ assemble_infix('^') -> i(?EXP);
|
|||||||
assemble_infix('bor') -> i(?OR);
|
assemble_infix('bor') -> i(?OR);
|
||||||
assemble_infix('band') -> i(?AND);
|
assemble_infix('band') -> i(?AND);
|
||||||
assemble_infix('bxor') -> i(?XOR);
|
assemble_infix('bxor') -> i(?XOR);
|
||||||
|
assemble_infix('bsl') -> i(?SHL);
|
||||||
|
assemble_infix('bsr') -> i(?SHR);
|
||||||
assemble_infix('<') -> i(?SLT); %% comparisons are SIGNED
|
assemble_infix('<') -> i(?SLT); %% comparisons are SIGNED
|
||||||
assemble_infix('>') -> i(?SGT);
|
assemble_infix('>') -> i(?SGT);
|
||||||
assemble_infix('==') -> i(?EQ);
|
assemble_infix('==') -> i(?EQ);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user