remove typed ops
This commit is contained in:
@@ -41,14 +41,8 @@ var streamline = function(ir, log) {
|
||||
max: true, min: true, pow: true
|
||||
}
|
||||
var bool_result_ops = {
|
||||
eq_int: true, ne_int: true, lt_int: true, gt_int: true,
|
||||
le_int: true, ge_int: true,
|
||||
eq_float: true, ne_float: true, lt_float: true, gt_float: true,
|
||||
le_float: true, ge_float: true,
|
||||
eq_text: true, ne_text: true, lt_text: true, gt_text: true,
|
||||
le_text: true, ge_text: true,
|
||||
eq_bool: true, ne_bool: true,
|
||||
eq_tol: true, ne_tol: true,
|
||||
eq: true, ne: true, lt: true, gt: true, le: true, ge: true,
|
||||
eq_tol: true, ne_tol: true, in: true,
|
||||
not: true, and: true, or: true,
|
||||
is_int: true, is_text: true, is_num: true,
|
||||
is_bool: true, is_null: true, is_identical: true,
|
||||
@@ -63,15 +57,10 @@ var streamline = function(ir, log) {
|
||||
|
||||
// simplify_algebra dispatch tables
|
||||
var self_true_ops = {
|
||||
eq_int: true, eq_float: true, eq_text: true, eq_bool: true,
|
||||
is_identical: true,
|
||||
le_int: true, le_float: true, le_text: true,
|
||||
ge_int: true, ge_float: true, ge_text: true
|
||||
eq: true, is_identical: true, le: true, ge: true
|
||||
}
|
||||
var self_false_ops = {
|
||||
ne_int: true, ne_float: true, ne_text: true, ne_bool: true,
|
||||
lt_int: true, lt_float: true, lt_text: true,
|
||||
gt_int: true, gt_float: true, gt_text: true
|
||||
ne: true, lt: true, gt: true
|
||||
}
|
||||
var no_clear_ops = {
|
||||
int: true, access: true, true: true, false: true, move: true, null: true,
|
||||
@@ -365,13 +354,6 @@ var streamline = function(ir, log) {
|
||||
load_index: [1, T_UNKNOWN], load_dynamic: [1, T_UNKNOWN],
|
||||
pop: [1, T_UNKNOWN], get: [1, T_UNKNOWN],
|
||||
invoke: [2, T_UNKNOWN], tail_invoke: [2, T_UNKNOWN],
|
||||
eq_int: [1, T_BOOL], ne_int: [1, T_BOOL], lt_int: [1, T_BOOL],
|
||||
gt_int: [1, T_BOOL], le_int: [1, T_BOOL], ge_int: [1, T_BOOL],
|
||||
eq_float: [1, T_BOOL], ne_float: [1, T_BOOL], lt_float: [1, T_BOOL],
|
||||
gt_float: [1, T_BOOL], le_float: [1, T_BOOL], ge_float: [1, T_BOOL],
|
||||
eq_text: [1, T_BOOL], ne_text: [1, T_BOOL], lt_text: [1, T_BOOL],
|
||||
gt_text: [1, T_BOOL], le_text: [1, T_BOOL], ge_text: [1, T_BOOL],
|
||||
eq_bool: [1, T_BOOL], ne_bool: [1, T_BOOL],
|
||||
eq_tol: [1, T_BOOL], ne_tol: [1, T_BOOL],
|
||||
not: [1, T_BOOL], and: [1, T_BOOL], or: [1, T_BOOL],
|
||||
is_int: [1, T_BOOL], is_text: [1, T_BOOL], is_num: [1, T_BOOL],
|
||||
@@ -1692,6 +1674,54 @@ var streamline = function(ir, log) {
|
||||
return result
|
||||
}
|
||||
|
||||
// DEF/USE classification: which instruction positions are definitions vs uses
|
||||
var slot_def_special = {
|
||||
get: [1], put: [], access: [1], int: [1], function: [1], regexp: [1],
|
||||
true: [1], false: [1], null: [1], record: [1], array: [1],
|
||||
invoke: [2], tail_invoke: [2], goinvoke: [],
|
||||
move: [1], load_field: [1], load_index: [1], load_dynamic: [1],
|
||||
pop: [1], frame: [1], goframe: [1],
|
||||
setarg: [], store_field: [], store_index: [], store_dynamic: [],
|
||||
push: [], set_var: [], stone_text: [],
|
||||
jump: [], jump_true: [], jump_false: [], jump_not_null: [],
|
||||
return: [], disrupt: []
|
||||
}
|
||||
|
||||
var slot_use_special = {
|
||||
get: [], put: [1], access: [], int: [], function: [], regexp: [],
|
||||
true: [], false: [], null: [], record: [], array: [],
|
||||
invoke: [1], tail_invoke: [1], goinvoke: [1],
|
||||
move: [2], load_field: [2], load_index: [2, 3], load_dynamic: [2, 3],
|
||||
pop: [2], frame: [2], goframe: [2],
|
||||
setarg: [1, 3], store_field: [1, 3], store_index: [1, 2, 3],
|
||||
store_dynamic: [1, 2, 3],
|
||||
push: [1, 2], set_var: [1], stone_text: [1],
|
||||
jump: [], jump_true: [1], jump_false: [1], jump_not_null: [1],
|
||||
return: [1], disrupt: []
|
||||
}
|
||||
|
||||
var get_slot_defs = function(instr) {
|
||||
var special = slot_def_special[instr[0]]
|
||||
if (special != null) return special
|
||||
return [1]
|
||||
}
|
||||
|
||||
var get_slot_uses = function(instr) {
|
||||
var special = slot_use_special[instr[0]]
|
||||
var result = null
|
||||
var j = 0
|
||||
var limit = 0
|
||||
if (special != null) return special
|
||||
result = []
|
||||
limit = length(instr) - 2
|
||||
j = 2
|
||||
while (j < limit) {
|
||||
if (is_number(instr[j])) result[] = j
|
||||
j = j + 1
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
var compress_one_fn = function(func, captured_slots) {
|
||||
var instructions = func.instructions
|
||||
var nr_slots = func.nr_slots
|
||||
@@ -2648,6 +2678,14 @@ var streamline = function(ir, log) {
|
||||
// Compress slots across all functions (must run after per-function passes)
|
||||
compress_slots(ir)
|
||||
|
||||
// Expose DEF/USE functions via log if requested
|
||||
if (log != null) {
|
||||
if (log.request_def_use) {
|
||||
log.get_slot_defs = get_slot_defs
|
||||
log.get_slot_uses = get_slot_uses
|
||||
}
|
||||
}
|
||||
|
||||
return ir
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user