From 01e9fc57b02d76006b252db449a5acb5265f04a0 Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Tue, 12 Sep 2017 21:43:50 -0400 Subject: Use imul (not sure if it's better...) --- register-allocate.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'register-allocate.py') diff --git a/register-allocate.py b/register-allocate.py index c517078bd..276deb46c 100755 --- a/register-allocate.py +++ b/register-allocate.py @@ -648,15 +648,27 @@ def print_mov_bucket(reg_out, reg_in, bucket): LAST_CARRY = None +def print_imul_constant(reg_out, reg_in, imm, src): + global LAST_CARRY + LAST_CARRY = None + ret = '' + assert(imm[:2] == '0x') + ret2, reg_in = print_load(reg_in, can_clobber=[reg_out]) + ret += ret2 + print_instr('imul', (reg_out, reg_in, imm), comment=src) + return ret + + def print_mul_by_constant(reg_out, reg_in, constant, src): #return '%s <- MULX %s, %s; // %s\n' % (ret_out, reg_in, constant, src) ret = '' - if constant == '0x13': - ret += ('// FIXME: lea for %s\n' % src) + #if constant == '0x13': + # ret += ('// FIXME: lea for %s\n' % src) assert(constant[:2] == '0x') + #return ret + \ + # print_load_constant('rdx', constant) + \ + # print_mulx(reg_out, 'rdx', 'rdx', reg_in, src) return ret + \ - print_load_constant('rdx', constant) + \ - print_mulx(reg_out, 'rdx', 'rdx', reg_in, src) + print_imul_constant(reg_out, reg_in, constant, src) def print_adx(reg_out, rx1, rx2, bucket): #return '%s <- ADX %s, %s; // bucket: %s\n' % (reg_out, rx1, rx2, bucket) -- cgit v1.2.3